Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何合并某些系列。`values\u count()`?_Python_Pandas - Fatal编程技术网

Python 如何合并某些系列。`values\u count()`?

Python 如何合并某些系列。`values\u count()`?,python,pandas,Python,Pandas,我有3个熊猫系列,我找到了它们的值\u count() 然后我想这样做: 把它们都放进一个数据包里。如果其中一个不在另一个数据集中,则放入0 A. 2 1 1 B. 8 4 9 D. 5 3 3 H. 0 7 7 L. 0 9 0 根据@anky的建议,您可以使用:- newdf=pd.concat([df1,df2,df3],axis=1) 使用后:- newdf=newdf.fillna(0).astype(int) 现在,如果您打印newdf,您将获得预

我有3个熊猫系列,我找到了它们的
值\u count()

然后我想这样做: 把它们都放进一个数据包里。如果其中一个不在另一个数据集中,则放入0

A. 2  1   1
B. 8  4   9
D. 5  3   3
H. 0  7   7
L. 0  9   0

根据@anky的建议,您可以使用:-

newdf=pd.concat([df1,df2,df3],axis=1)
使用后:-

newdf=newdf.fillna(0).astype(int)
现在,如果您打印
newdf
,您将获得预期的输出:-

A   2   1   1
B   8   4   9
D   5   3   3
H   0   7   7
L   0   9   0

根据@anky的建议,您可以使用:-

newdf=pd.concat([df1,df2,df3],axis=1)
使用后:-

newdf=newdf.fillna(0).astype(int)
现在,如果您打印
newdf
,您将获得预期的输出:-

A   2   1   1
B   8   4   9
D   5   3   3
H   0   7   7
L   0   9   0

l=[df1,df2,df3]
然后
pd.concat(l,axis=1,sort=False)
?您可以查看该网站,有许多选项需要执行
l=[df1,df2,df3]
然后
pd.concat(l,axis=1,sort=False)
?您可以查看该网站,有许多选项需要执行。谢谢,我能把A,B,D,H,L转换成一个新的列吗。它现在似乎是索引。是的,它是索引。我能把它变成一个新的列吗?是的,只要使用
newdf=newdf.reset\u index()
newdf.reset\u index(inplace=True)
谢谢。我能把a、B、D、H、L转换成一个新的列吗。现在它似乎是索引。是的,它是索引。我能把它变成一个新列吗?是的,只要使用
newdf=newdf.reset\u index()
newdf.reset\u index(inplace=True)