[英]Shift entire column on a pandas dataframe
I want to shift to the right an entire column, fill with NAN the first column and drop the last column: 我想向右移动整个列,在第一列填充NAN并删除最后一列:
df0: A B C D
2013-12-31 10 6 6 5
2014-01-31 11 7 5 5
2014-02-28 15 8 8 8
into 成
df1: A B C D
2013-12-31 NaN 10 6 6
2014-01-31 NaN 11 7 5
2014-02-28 NaN 15 8 8
My solution is to split the columns into Series and then recompose the dataframe. 我的解决方案是将列拆分为Series,然后重新组合数据帧。 Is there a more efficient way?
有更有效的方法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.