我有一系列七个相同长度的数据帧。你知道吗
日期1看起来像:
month day year
0 04 20 2009
1 04 20 09
2 4 20 09
3 4 3 09
4 NaN NaN NaN
5 NaN NaN NaN
6 NaN NaN NaN
7 NaN NaN NaN
8 NaN NaN NaN
...
日期2看起来像:
month day year
0 NaN NaN NaN
1 NaN NaN NaN
2 NaN NaN NaN
3 NaN NaN NaN
4 Mar 20 2009
5 Mar 20 2009
6 Mar 20 2009
7 Mar 20 2009
8 Mar 20 2009
...
等等,更新7。我想创建一个数据帧,将它们合并在一起,但合并似乎不适合我。你知道吗
以下是我目前正在做的:
alldates = pd.concat([dates1,dates2,dates3,dates4], axis=0)
return alldates.dropna()
这是可行的,但一旦我加上date5,date6,date7,它就开始混乱了,因为那些数据帧有一些与alldates具有相同索引值的行。你知道吗
我被这个难住了。我还需要提供什么信息?有没有更优雅的方法来解决这个问题?你知道吗
也许你只需要在连接后删除重复的索引,只保留第一个索引,即
如果您试图从其他数据帧填充nan值,那么您可以使用
对于两个以上的数据帧
您可以尝试如下使用append:
相关问题 更多 >
编程相关推荐