Using 'isin' On A Date In A Pandas Column
I have the following code that results in the following dataframe: date=['1/1/2016','2/2/2017','4/8/2017','3/3/2015'] distance=['10','20','30','40'] dd=list(zip(date,distance)) df=
Solution 1:
df['date'] = pd.to_datetime(df['date'])
df = df[df['date'].dt.year == 2017]
Solution 2:
If all you want is to filter '2017'. Then do it.
df[df.date.str.endswith('2017')
Post a Comment for "Using 'isin' On A Date In A Pandas Column"