+ 2
How to print without Name attribute in pandas python?
I’m getting an error on 3rd project in DS with Python course (SoloLearn) because I have an Name attribute. import numpy as np import pandas from pandas import DataFrame from numpy import nan lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] df = pandas.DataFrame(lst) df.fillna(df.mean(), inplace =True) #df=df.replace(np.NaN, df.mean()) print(df[0].round(1)) Output: *.....* Name: 0, Dtype: float64 Expected output: *....* Dtype: float64
2 odpowiedzi
+ 2
Try to use Series instead of DataFrame.
Then remove the index of the series to print all columns.
And by the way, when importing modules, you dont need to import its function and module if you want to use a particular function at the same time vice versa.
_______________________
import numpy as np
import pandas
lst = [float(x) if x != 'nan' else np.NaN for x in input().split()]
df = pandas.Series(lst)
df.fillna(df.mean(), inplace =True)
print(df.round(1))
+ 1
df[0].dtype