当我在
下面运行for循环时for i in df:
d = df[pd.notnull(df[i])]
c = df[df[i]>str(1)].count()
print(c)
我在下面得到了一个结果
1 244
2 122
3 53
4 75
dtype: int64
1 122
2 206
3 62
4 77
dtype: int64
我想创建一个如下所示的数据框
1 2
1 244 122
2 122 206
3 53 62
4 75 77
有人可以帮我编码吗?
答案 0 :(得分:1)
Having an excerpt of your initial data would be useful, but from what I can gather you're only trying to append the two arrays together to obtain a pandas dataframe. That can be easily done with something like:
data = pd.DataFrame()
for i in df:
d = df[pd.notnull(df[i])]
c = df[df[i]>str(1)].count()
data = data.join(c)
print(data)