0

When I run the for loop below

for i in df:
    d = df[pd.notnull(df[i])]
    c = df[df[i]>str(1)].count()
    print(c)

I get a results below

1     244
2     122
3      53
4      75
dtype: int64
1     122
2     206
3      62
4      77
dtype: int64

I want to create a data frame which looks like below

   1   2
1 244 122
2 122 206
3  53  62
4  75  77

Can someone help me code?

Ryo
  • 157
  • 2
  • 3
  • 15
  • Possible duplicate of [Append column to pandas dataframe](https://stackoverflow.com/questions/20602947/append-column-to-pandas-dataframe) – Jeanne Chaudanson Jul 20 '17 at 12:25

1 Answers1

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)