如何在系列开始时添加/插入项目? [英] how to append/insert an item at the beginning of a series?
本文介绍了如何在系列开始时添加/插入项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想象我有一个系列看起来像这样:
imaging i have a series looks like this:
Out[64]:
2 0
3 1
80 1
83 1
84 2
85 2
如何在本系列的开头添加一个项目?本地的pandas.Series.append函数仅在末尾追加.
how can i append an item at the very beginning of this series? the native pandas.Series.append function only appends at the end.
非常感谢
推荐答案
有一个pandas.concat
函数...
import pandas as pd
a = pd.Series([2,3,4])
pd.concat([pd.Series([1]), a])
请参见合并,加入和连接文档.
这篇关于如何在系列开始时添加/插入项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文