5 Answers
New AnswerHello, i wanna ask about something I wanna know how this code works, it actually has been used for lots of question in datascience project in sololearn lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] One of the full code example down here :. Import numpy as np Import pandas as pd lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] lst_df = pd.Series(lst) Sylv = lst_df.fillna(lst_df.mean()).round(1) print(Sylv)
4/9/2021 8:39:34 AM
Sylvanast5 Answers
New Answerlst = [float(x) if x != 'nan' else np.NaN for x in input().split()] Its generator And equal this: lst =[] For x in input().split(): if x =! 'nan': lst.append(float(x)) else: lst.append(np.NaN)
list comprehension: https://www.sololearn.com/learning/2454/ cant post a link that works so look for it in python tutorial
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message