如何在索引 pandas 的帮助下填充行?
how to fill rows with help of index pandas?
如何借助索引pandas填充行?
我有这样的数据框
Alert number Age Job Loan
0 0 58 4 0
2 2 44 9 0
4 4 35 4 0
6 6 41 0 0
8 8 29 0 0
我有另一个具有相同列数和不同索引值的数据框,例如
Alert number Age Job Loan
1 1 58 4 0
3 3 44 9 0
5 5 35 4 0
7 7 41 0 0
9 9 29 0 0
如何在pandas中将以上两行顺序合并?
喜欢下面的数据框
Alert number Age Job Loan
0 0 58 4 0
1 1 58 4 0
2 2 44 9 0
3 3 44 9 0
4 4 35 4 0
5 5 35 4 0
6 6 41 0 0
7 7 41 0 0
8 8 29 0 0
9 9 29 0 0
使用concat
with sorting by DataFrame.sort_values
:
df = pd.concat([df1, df2]).sort_values('Alert number', ignore_index=True)
df = pd.concat([df1, df2]).sort_index()
如何借助索引pandas填充行?
我有这样的数据框
Alert number Age Job Loan
0 0 58 4 0
2 2 44 9 0
4 4 35 4 0
6 6 41 0 0
8 8 29 0 0
我有另一个具有相同列数和不同索引值的数据框,例如
Alert number Age Job Loan
1 1 58 4 0
3 3 44 9 0
5 5 35 4 0
7 7 41 0 0
9 9 29 0 0
如何在pandas中将以上两行顺序合并?
喜欢下面的数据框
Alert number Age Job Loan
0 0 58 4 0
1 1 58 4 0
2 2 44 9 0
3 3 44 9 0
4 4 35 4 0
5 5 35 4 0
6 6 41 0 0
7 7 41 0 0
8 8 29 0 0
9 9 29 0 0
使用concat
with sorting by DataFrame.sort_values
:
df = pd.concat([df1, df2]).sort_values('Alert number', ignore_index=True)
df = pd.concat([df1, df2]).sort_index()