import pandas as pd
import statistics
df=print(pd.read_csv('001.csv',keep_default_na=False, na_values=[""]))
print(df)
I am using this code to create a data frame which has no NA values. I have couple of CSV files and I want to calculate Mean of one of the columns - sulfate. This column has many 'NA' values, which I am trying to exclude. Even after using the above code, 'NA's aren't excluded from the data frame.
Please suggest.
解决方案
I think you should import the .csv file as it is and then manipulate the data frame.
Then, you can use any of the methods below.
foo[foo.notnull()]
or
foo.dropna()