# Missing numbers DS python

Where is the problem with this solution? import numpy as np import pandas as pd lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] n = pd.DataFrame(lst) n.fillna(round(n.mean(), 1), inplace = True) print(n[0])

3/27/2021 9:47:04 PM

Ahmed Azami Hassani2 Answers

New AnswerI am not sure, if this is the exact problem (did not run your code), but I used a pd.Series instead of a pd.DataFrame (the output layout slightly diverges) https://www.sololearn.com/discuss/2630791/?ref=app

The trick is turning the output into a string. Below worked for me. import numpy as np import pandas as pd lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] df = pd.DataFrame(lst) df = df.fillna(df.mean().round(1)) print(df[0].to_string()) print('dtype: '+str(df[0].dtypes))