How to print without Name attribute in pandas python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

18th Dec 2020, 10:42 AM
BatOchir Artur
BatOchir Artur - avatar
2 Answers
+ 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))
26th Jan 2021, 12:36 AM
noteve
noteve - avatar
+ 1
df[0].dtype
18th Dec 2020, 1:27 PM
Lisa
Lisa - avatar