Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /