The problem is in line 22 :
if start_date <= data_entries.iloc[j, 1] <= end_date:
where I want to compare the start_date
and end_date
portion to data_entries.iloc[j, 1]
which is accessing a column of the pandas dataframe. I converted the column to datetime using,
data_entries['VOUCHER DATE'] = pd.to_datetime(data_entries['VOUCHER DATE'], format="%m/%d/%Y")
But I am unsure how to convert it to date.
import pandas as pd
import datetime
entries_csv = "C:\\Users\\Pops\\Desktop\\Entries.csv"
data_entries = pd.read_csv(entries_csv)
data_entries['VOUCHER DATE'] = pd.to_datetime(data_entries['VOUCHER DATE'], format="%m/%d/%Y")
start_date = datetime.date(2018, 4, 1)
end_date = datetime.date(2018, 10, 30)
for j in range(0, len(data_entries)):
if start_date <= data_entries.iloc[j, 1] <= end_date:
print('Hello')