Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Last active March 27, 2021 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyishaR/0c3ac2f4b962fe8a7aef4fb669f18d6c to your computer and use it in GitHub Desktop.
Save AyishaR/0c3ac2f4b962fe8a7aef4fb669f18d6c to your computer and use it in GitHub Desktop.
numeric_columns = ['distance','consume','temp_inside','refill liters'] # columns with ','
for column in numeric_columns:
#print(column)
x = [x.replace(',','.') for x in df[column].values]
df[column] = list(map(np.float32, x))
#including other numeric columns
numeric_columns.extend(['speed','temp_outside'])
# Defining the dataypes
for column in df.columns:
if column in numeric_columns:
df[column] = df[column].astype('float32')
else:
df[column] = df[column].astype('int64')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment