[英]AttributeError: module 'pandas' has no attribute 'df'
For a current project, I am planning to clean a Pandas DataFrame off its Null values.对于当前项目,我计划从 Null 值中清除 Pandas DataFrame 值。 For this purpose, I want to use
Pandas.DataFrame.fillna
, which is apparently a solid soliton for data cleanups.为此,我想使用
Pandas.DataFrame.fillna
,这显然是用于数据清理的固体孤子。
When running the below code, I am however receiving the following error AttributeError: module 'pandas' has no attribute 'df'
.但是,在运行以下代码时,我收到以下错误
AttributeError: module 'pandas' has no attribute 'df'
。 I tried several options to rewrite the line df = pd.df().fillna
, none of which changed the outcome.我尝试了几个选项来重写
df = pd.df().fillna
,但都没有改变结果。
Is there any smart tweak to get this running?有什么聪明的调整可以让它运行吗?
import string
import json
import pandas as pd
# Loading and normalising the input file
file = open("sp500.json", "r")
data = json.load(file)
df = pd.json_normalize(data)
df = pd.df().fillna
When you load the file to the pandas - in your code the data
variable is a DataFrame
instance.当您将文件加载到 pandas - 在您的代码中,
data
变量是DataFrame
实例。 However, you made a typo.然而,你打错了。
df = pd.json_normalize(data)
df = df.fillna()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.