我正在尝试使用 Pandas Drop 函数删除两列。但是,我收到错误。仅供参考,我已经打印了数据框的列名。为什么我会收到这样的错误?
在 [284] 中:Fulldf.columns
Out[284]:
Index(['PID', 'YearBuilt', 'YearRemodel', 'VeneerExterior', 'BsmtFinTp',
'BsmtFinSqft', 'BsmtUnfinSqft', 'HeatingQC', 'FstFlrSqft', 'SecFlrSqft',
'AbvGrndLiving', 'FullBathBsmt', 'HalfBathHouse', 'FullBathHouse',
'BdrmAbvGrnd', 'RmAbvGrnd', 'Fireplaces', 'GarageTp', 'GarageCars',
'GarageArea', 'WdDckSqft', 'OpenPrchSqft', 'LotArea', 'LotShape',
'BldgTp', 'OverallQuality', 'OverallCondition', 'SalePrice'],
dtype='object')
print(f'Total number of input variables to preprocess: {Fulldf.drop(['SalePrice', 'PID'], axis=1).shape[1]})
**strong text**
In [285]:
File "<ipython-input-287-7da1b9aca26a>", line 1
print(f'Total number of input variables to preprocess: {Fulldf.drop(['SalePrice', 'PID'], axis=1).shape[1]})
^
SyntaxError: invalid syntax