How can I make a summary of a data frame in Pandas, stacking individual operations.
For example, I used the following code:
df=pd.DataFrame(wb)
# Get list with headers
header1 = list(df)
count=df.count()
NaNs=df.isnull().sum()
sum=df.sum(0)
mean=df.mean()
median=df.median()
min= df.min()
max= df.max()
standardeviation= df.std()
nints=df.dtypes
But I can only print them as individual results. I get something like this for each calculation:
Unnamed: 0 60
region 50
IV_bins 60
N 60
meanbase 60
cash 60
dtype: int64
Finally, I tried creating a summarytable=[] table at the beginning and trying something like summarytable.append(count) and so on with all the calculations, but couldn't get it right. What I am looking for is some table like this, which I believe also involves transposing the calculations:
A B
Count 100 98
NANs 5 7
Mean 10 12.5
Median 14 8
...
Nints 95 96
NStr 5 2
One last thing to take into account. I noticed that for some calculations, like sum(), it doesn't make sense to count strings, so, when I print the results, the strings columns don't print anything. This is the result for print(sum): (Notice how region doesn't appear)
Unnamed: 0 1830
IV_bins [0,2.31e+06](2.31e+06,5.7e+06](5.7e+06,1.07e+0...
N 3680163
meanbase 3.46248
cash 9.00091e+09
sum=df.sum(0),min= df.min(),max= df.max()- you just destroyed three useful built-in functions.sum=df.sum(0)makes the buil-in functionsum()unavailable (same with the outher two functions).