Reputation: 1
I am trying to drop two columns using Pandas Drop function. However, I am receiving error. FYI I have printed column names of the data-frame. Why am I receiving such error?
In [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
Upvotes: 0
Views: 102
Reputation: 19957
You are mixing single quotes and double-quotes. Can you try this?
print(f"Total number of input variables to preprocess: {Fulldf.drop(['SalePrice', 'PID'], axis=1).shape[1]}")
Upvotes: 3