Missing numbers | Sololearn: Learn to code for FREE!

+4

Missing numbers

I solved this project and got the outputs well but it wont stop showing a zero on top of my output and it wasn't approved... Any help??? This is the code below.... import numpy as np import pandas as pd lst = [float(x) if x != 'nan' else np.NaN for x in input().split()] list = [num for num in lst if num==float(num)] mean = round(np.mean(list), 1) df = pd.DataFrame(lst) df1 = df.fillna(value=mean) print(df1)

12/30/2020 10:29:37 AM

prince taoheed tesla

7 Answers

New Answer

+2

I've solved the question last week... I somehow figured it out.

+2

while the question asks to convert the input to dataframe, don't do it. think of alternates that will not print column name. i just solved it.

+2

As srikanth murthi says: don't use a DataFrame, even though that is what the project says you should do Use a Series instead. Then the print output will be in the correct format.

+1

I try to call print(df[0]), but still no success. It seems like this project was made for some old version of pandas

+1

Managed to solve it)) First snippet of code form here helps a lot: https://pandas.pydata.org/pandas-docs/stable/user_guide/10min.html#object-creation

0

The top 0 is a column name, its like Excel, very similar to Excel. Since you did not make a column name, a 0 is in its place. You have options, Pandas is very flexible. I dont know what your output should be, but take a look at some options you have... https://code.sololearn.com/c9BKQqJUgIqY/?ref=app

0

Here is my Code On "Missing Numbers" Code coach Using python n=int((input())) l=[] m=" " for i in range(n): g=int(input()) l.append(g) s=l[0] g=l[n-1] for i in range(s,g,1): if(i in l): continue else: m=m+str(i)+" " print(m) #created by pardhu:)