Pandas DF related problem - MISSING NUMBERS | Sololearn: Learn to code for FREE!


Pandas DF related problem - MISSING NUMBERS

''' In DS with Py, one of the end of module tasks, Given a list of numbers including some missing values, turn it into a pandas dataframe, impute the missing values with the mean, and finally return the dataframe. I have solved this challenge by not doing exactly the same as instructed and that's why even after solving the challenge, I am stuck here trying to find a way to do as said. ''' import numpy as np import pandas as pd lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] df = pd.Series(lst) df = df.fillna(round(df.mean(),1)) print (df) Whenever I change that to df = pd.DataFrame(lst) Column name is automatically given as 0, which is expected but When I try to return that column like this Print (df.iloc[:,0] It prints everything fine but has one extra Name= 0 (for that column name) in the result and due to that, test doesn't pass. Can you suggest to get the expected output using pd.DataFrame??? Thanks in Advance!!!

4/11/2021 4:23:08 AM


3 Answers

New Answer


🅰🅹 (Challenge Accepted) Is there a way to remove that thing??


Tony F 🐙 thanks for your response. I had solved this challenge before writing this query. I just wanted to know if there is a solution to the questions I have raised?


I think of myself as an ok Python and SQL developer, but I just can't grasp pandas. I have a simple task to build some gantt-type graphs from simple set of tasks with transfer speed and start/end dates, but I just can't wrap my mind around it. So, what's the best way to learn pandas?