Skip to content

Instantly share code, notes, and snippets.

@kalugny
Created November 14, 2017 15:04
Show Gist options
  • Save kalugny/8ec463b284cacc549849639e40e03c21 to your computer and use it in GitHub Desktop.
Save kalugny/8ec463b284cacc549849639e40e03c21 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
# coding: utf-8
# In[2]:
import numpy as np
import pandas as pd
from datetime import datetime
# In[3]:
xl = pd.ExcelFile("NYPD_Ilan.xlsx")
# In[4]:
xl.sheet_names
# In[9]:
df = xl.parse("NYPD_Complaint_Data_Historic")
# In[7]:
for i in range(0, 100):
if type(df['CMPLNT_FR_DT'][i])==str:
df['CMPLNT_FR_DT'][i]= datetime.strptime(df['CMPLNT_FR_DT'][i], '%m/%d/%Y')
print(type(df['CMPLNT_FR_DT'][10]))
# In[ ]:
for i in range(100, 1048575):
if type(df['CMPLNT_FR_DT'][i])==str:
df['CMPLNT_FR_DT'][i]= datetime.strptime(df['CMPLNT_FR_DT'][i], '%m/%d/%Y')
print(type(df['CMPLNT_FR_DT'][10]))
# In[1]:
df2 = df.head(5)
df2
# In[31]:
type(df2['CMPLNT_FR_DT'][2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment