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?

1

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.