'Filter row records based on particular date format in pyhon
Can anyone help me python code for filter records after particular date present in csv file,date column,having format DD/MM/YY-HH:MM:SS
Solution 1:[1]
Content of filter_df_by_date.csv file is presented below. Dates are in DD/MM/YY-HH:MM:SS format.
date,data
01/01/22-10:15:32,A
01/03/22-12:10:15,B
Possible solution is the following:
import pandas as pd
# read data from csv file and parse dates to datetime format
df = pd.read_csv("filter_df_by_date.csv", parse_dates=['date'], dayfirst=True)
df
# filter dataframe by date column
df = df[(df['date'] > '2022-01-02')]
# or if you need to be more precise
# df = df[(df['date'] > '2022-01-02 00:00:00')]
df
Returns
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


