When i have entered my dataset and converted from object to int, all the values are changing to NaN.
This is my code:
iron_map = {'No': 1, 'Steady': 2, 'Down': 3, 'Up': 4}
df['iron'] = df['iron'].map(iron_map)
df['iron'] = df['iron'].astype(int)
or alternatively it happened on this one too:
df['number_hospital_visits'] = df['number_hospital_visits'].astype(str)
df = df[df['number_hospital_visits'].str.isnumeric()] - *I did this as some values were "?" so converted to string first then int*
df['number_hospital_visits'] = df['number_hospital_visits'].astype(int)
Anyone know how to fix this?
EDIT:
Have attached an example of the df data:
