I have the following dataset and function to try to detect if the columns are date types.
from dateutil.parser import parse
import pandas as pd
# function
def is_date(string, fuzzy=False):
try:
parse(string, fuzzy=fuzzy)
return True
except ValueError:
return False
# data
df = pd.read_csv('https://data.calgary.ca/api/views/78gh-n26t/rows.csv?accessType=DOWNLOAD')
When I try the function on one of the columns is_date(crime['Date'])
I get:
TypeError: Parser must be a string or character stream, not Series
How do I properly convert the column into the correct type to be able to loop through all values with the function?
Date column:
0 05/01/2020 12:00:00 AM
1 05/01/2020 12:00:00 AM
2 04/01/2020 12:00:00 AM
3 04/01/2020 12:00:00 AM
4 04/01/2020 12:00:00 AM
Other columns:
Sector Community Name Category
NORTHWEST 02E Assault (Non-domestic)
WEST ASPEN WOODS Street Robbery
NORTHWEST 02E Violence Other (Non-domestic)
NORTH 02K Theft OF Vehicle
NORTHEAST 10E Break & Enter - Commercial