Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print coulmn name in saved csv file using python

Tags:

python

csv

I want to know that how much null values exist in every column of my data. As my data is too large I am saving the result in csv to get a clear picture. But the problem is in my csv, I am unable to see the column name. What should i do to to print the column name against the sum of null values in my CSV file?

  aw= data.isnull().sum()
  aw.to_csv (r'C:/Users/a.csv', index = False, header=True)

my CSV file looks like this 0 0 0 10 0 9

I want to see it like this

feature1 0 feature2 0 feature3 0 feature4 11 feature5 12 feature6 12

like image 871
user12 Avatar asked Dec 18 '25 10:12

user12


1 Answers

the resulting aw is not a DataFrame. To check type(aw) output pandas.core.series.Series

what you could try is

aw = pd.DataFrame(data.isnull().sum()).T

the output is

    feature1    feature2    feature3
0   0           0           0
like image 63
Black Raven Avatar answered Dec 20 '25 22:12

Black Raven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!