【发布时间】:2019-11-02 17:12:42
【问题描述】:
我尝试了各种方法将新列添加到 Panda dataframe 但我得到了相同的结果。
尝试的方法:
call_duration 是一个列表,其项目数与数据框中的项目数相同。
df['Duration_sec'] = pd.Series(call_duration,index=np.arange(len(df)))
和
df['Duration_sec'] = pd.Series(call_duration,index=df.index)
和
# df['Duration_sec'] = np.array(call_duration)
我不明白为什么将新列添加到新行?为什么第一行末尾有一个\?
【问题讨论】:
-
请花时间阅读how to provide a great pandas example 和Please don't post images of code/data (or links to them) 上的这篇文章,但我们可以将其复制为文本
-
好的。下次会记住的。谢谢!
标签: python python-3.x pandas list dataframe