I have a dataset that I want to clean. The data set consists of 54 columns and 315 rows. For one of the columns, I want to find whether all the values in that column are numeric or not. I have done the following:
work_sheet = pd.read_excel('2006_sale.xlsx', sheet_name='Sheet1')
df = work_sheet.copy()
TRY 1
for idx,val in enumerate(df['LotArea']):
if(not(str(val).isnumeric())): # Check if a value is numeric or not
df.at[idx,'LotArea'] = np.nan # If the value is not numeric then replace it with null
TRY 2
for idx,val in enumerate(df['LotArea']):
if(not(isinstance(val,float))): # Check if a value is numeric or not
df.at[idx,'LotArea'] = np.nan # If the value is not numeric then replace it with null
Problem with both the approach
Somehow it is detecting each value as non-numeric and my final output looks like this:
Any idea where i am going wrong?