Skip to content

Instantly share code, notes, and snippets.

@fruch
Created April 16, 2020 12:20
Show Gist options
  • Save fruch/02ea79e7559947c4619db272be9793b7 to your computer and use it in GitHub Desktop.
Save fruch/02ea79e7559947c4619db272be9793b7 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import csv
input = ""
for l in open('/home/fruch/Downloads/data_short.csv').readlines():
input += l.replace('"', '') + '\n'
with open('/home/fruch/Downloads/data_short_clean.csv', 'w') as f:
f.write(input)
data = pd.read_csv('/home/fruch/Downloads/data_short_clean.csv', encoding='utf-8')
print(data.keys())
dataTypeSeries = data.dtypes # check the type of each column
print(data)
print('Data type of columns :')
print(dataTypeSeries)
data['cases'] = data['cases'].apply(pd.to_numeric)
print(data)
dataTypeSeries = data.dtypes # check the type of each column
print('Data type of columns :')
print(dataTypeSeries)
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment