Here is my code:
import pandas as pd
from datetime import date
date = pd.read_csv("D:\Python_program\DATE.csv")
date.head(5)
date[pd.to_datetime(date['sr_date']) > pd.Timestamp(date('08-08-2021'))]
date
Then I get the error messave:
error:- TypeError: 'DataFrame' object is not callable
Please help me.
As @Randy mentions in the comment, you're over-riding the name date
from the import line:
from datetime import date
when you read in your dataframe:
date = pd.read_csv("D:\Python_program\DATE.csv")
Now date
no longer refers to datetime.date
but to the dataframe.
(EDIT) Furthermore, correct usage of pd.Timestamp
from the docs would look like this, so you don't need the date
function:
import pandas as pd
df = pd.read_csv("D:\Python_program\DATE.csv")
df[pd.to_datetime(df['sr_date']) > pd.Timestamp(2021, 8, 8)]