Skip to content

Commit a899c5a

Browse files
committed
提交代码
1 parent 9e7b1e8 commit a899c5a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

qingxiangke/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ Python技术 公众号文章代码库
1515

1616
[pandas条件筛选](https://github.com/JustDoPython/python-examples/tree/master/qingxiangke/PandasSift) : pandas的多条件筛选
1717

18-
[pandas的多表连接](https://github.com/JustDoPython/python-examples/tree/master/qingxiangke/pandasMerge) : pandas的多表连接
18+
[pandas的两表连接](https://github.com/JustDoPython/python-examples/tree/master/qingxiangke/pandasMerge) : pandas的两表连接
19+
20+
[pandas的多表拼接](https://github.com/JustDoPython/python-examples/tree/master/qingxiangke/calculate) : pandas的多表拼接

qingxiangke/calculate/main.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pandas as pd
2+
3+
df1 = pd.DataFrame({
4+
'姓名': ['张三', '李四', '王五', '刘六', '齐四'],
5+
'号码': ['123', '456', '789', '987', '654']
6+
})
7+
8+
df2 = pd.DataFrame({
9+
'姓名': ['张三', '张三', '张三', '李四', '李四', '李四', '李四', '王五', '王五', '刘玉', '胡军', '刘玉', '刘六', '刘六', '刘六', '刘六', '刘克', '刘玉', '齐七', '齐七', '齐七', '齐七', '冯亮', '刘玉', '王云'],
10+
11+
'号码': ['123', '456', '789', '123', '123', '456', '456', '456', '456', '456', '741', '741', '741', '741', '741', '789', '789', '789', '789', '789', '852', '852', '852', '852', '852'],
12+
13+
'日期': ['2022-03-13', '2022-03-06', '2022-01-30', '2022-01-04', '2022-02-26', '2022-03-26', '2022-03-06', '2022-01-30', '2022-01-29', '2022-03-13', '2022-03-06', '2022-02-19', '2022-02-04', '2022-03-10', '2022-04-19', '2022-03-10', '2022-01-29', '2022-02-19', '2022-03-06', '2022-03-26', '2022-01-04', '2022-02-04', '2022-04-19', '2022-02-26', '2022-03-06'],
14+
15+
'方案': ['G1012', 'G1022', 'G1002', 'G1007', 'G1017', 'G1023', 'G1018', 'G1003', 'G1008', 'G1013', 'G1020', 'G1015', 'G1010', 'G1005', 'G1025', 'G1004', 'G1009', 'G1014', 'G1019', 'G1024', 'G1006', 'G1011', 'G1026', 'G1016', 'G1021']
16+
})
17+
18+
df3 = pd.DataFrame({
19+
'姓名': ['张三', '李四', '王五', '刘六', '齐四'],
20+
'号码': ['123', '456', '789', '987', '654'],
21+
'年龄': ['25', '36', '41', '12', '54']
22+
})
23+
24+
# 上下拼接
25+
df = pd.concat([df1, df2, df3], axis=0)
26+
27+
# 左右拼接
28+
df = pd.concat([df1, df2, df3], axis=0)
29+
30+
print(df)

0 commit comments

Comments
 (0)