+ 5
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)
8 Respostas
+ 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.
+ 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
+ 1
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:)
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
listed = []
for i in range(int(input())):
listed.append(int(input()))
full = list(range(listed[0],listed[-1]))
diff = set(full) ^ set(listed)
print(*list(diff)[:-1])
0
import numpy as np
import pandas as pd
last = [float(x) if x != 'nan' else np.NaN for x in input().split()]
tota=np.array(last)
avg=(pd.Series(last)).mean().round(1)
tota=np.nan_to_num(tota , nan=avg)
print(pd.Series (tota))