我已导入csv文件并找出空值。我在价格13396中找到了空值。
df = pd.read_csv(r'D:\Data Analyst\Data Analyst with python\winemag.csv',sep=';')
df.isnull().sum()
国家----- 2
价格------- 13396
使用下面的for语句填充值后,我仍然在价格5中找到空值
frames=[]
for i in list(set(df['country'])):
df_country = df[df['country']==i]
df_country.price.fillna(df_country.price.mean(),inplace=True)
frames.append(df_country)
final_df = pd.concat(frames)
国家---- 0
价格------- 5
您能帮我找出哪个国家/地区的价格值为空
答案 0 :(得分:0)
如果一个特定国家/地区的所有价格均为NaN,则其均值也将返回NaN。
尝试运行
class Message(object):
def __init__(self,parent, *args, **kwargs):
self.parent=parent
top=Toplevel(self.parent)
top.geometry("400x200")
top.transient(self.parent)
top.title(args[0])
f0=Frame(top)
top.l1=Label(f0, text=args[1])
top.l1.pack(pady=30)
f0.pack()
top.grab_set()
top.f1=Frame(top)
for key in kwargs:
key=Button(top.f1, text=f"{kwargs[key]}")
key.pack(side=LEFT)
top.f1.pack()
准确调查哪些行仍具有NaN值