[英]Add columns to end of dataframe based on dynamic number of Columns
我有一个数据框,其中的列数逐月变化。 我想在每个数据帧的末尾创建 3 个空列。
我使用insert
但因为列数逐月变化我留下了错误
IndexError: index 59 is out of bounds for axis 0 with size 58
我的代码:
netnewprocess.insert(59, 'date', '')
netnewprocess.insert(60, 'Analyst Review', '')
netnewprocess.insert(61, 'SM Review', '')
如果您只是像这样添加一列,它将将该列附加到您的 DataFrame 的右侧,并且您不需要指定索引:
netnewprocess['date'] = ''
netnewprocess['Analyst Review'] = ''
netnewprocess['SM Review'] = ''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.