+ 1

# Module 3 Quiz - Data Science

My problem is in the Quiz of module 3, from Data Science course. It could be said that I already have solved this problem, but at the end of my output there is something that I do not want, I mean, IDK how to quit that part; what I'm talking about is this: Name: 0, dtype: float64 I would like to have just the 'dtype', so what could I do, my code is the following if you want to check and tell me if something I put is causing this: import pandas as pd import numpy as np lst = [float(x) if x != 'nan' else 'NaN' for x in input().split()] new_lst = [] for j in lst: if j == 'NaN': continue else: new_lst.append(j) mean = np.mean(new_lst) for i in lst: if i == 'NaN': index = lst.index(i) lst.remove(i) lst.insert(index, mean.round(1)) else: continue lst = pd.DataFrame(lst) print(lst)

14th Apr 2021, 1:18 AM
Bry4n + 2
Think more about Pandas Series, because the output, it looks like a series, your output is a dataframe... something like this? https://code.sololearn.com/cfag9BiW4MO5/?ref=app
14th Apr 2021, 1:36 AM
Steven M + 3
Sometimes you don't need to drop the whole row especially when you are preparing your data for a classifier.. fillna() fills the position of NaN values with the given argument.
14th Apr 2021, 3:46 AM
Ahmed Yasser + 3
Oh that's fairly handy, thanks Ahmed Yasser :D
14th Apr 2021, 4:25 AM
Bry4n + 2
( •_•)>⌐■-■ Dude I forgot about series, you cannot be more right, thanks a lot you solve my problem :D
14th Apr 2021, 3:07 AM
Bry4n + 2
import numpy as np r = int(input()) lst = [float(x) for x in input().split()] arr_ABD = np.array(lst) arr_ABD = arr_ABD.reshape(r,int(len(lst)/r)) print(arr_ABD.round(2))
14th Sep 2021, 7:45 AM + 1
Just a question, how does the function fillna() works?? I mean when I have to use it, I cannot entirely get it.
14th Apr 2021, 3:10 AM
Bry4n + 1
Copy this code answer and like and check thank-you
14th Sep 2021, 7:46 AM  