user14899825
user14899825

Reputation: 1

Lack of desired output

In the code below, I am trying to get data for a specified date only. It perfectly works for the shown code.

But if I change the date to 26-12-2020, it results in data of both 26-12-2020 and 27-12-2020.

import csv
import datetime
import os
import pandas as pd
import xlsxwriter 
import numpy as np
from datetime import date
import datetime
import calendar  

rdate = 27-12-2020

data= pd.read_excel(r'C:/Clover Workspace/NPS/Customer Feedback-28-12-2020.xlsx')
data.drop(columns=['User ID','Comments','Purpose ID'],inplace= True, axis=1)
df = pd.DataFrame(data, columns=['Name','Rating','Date','Store','Feedback choice'])
df['Date'] = pd.to_datetime(data['Date'])
df= df[df['Date'].ge("27-12-2020")]

How can I generate the output only for the specified date, irrespective of the date on the excel sheet name?

Upvotes: 0

Views: 31

Answers (1)

Artyom Akselrod
Artyom Akselrod

Reputation: 976

here:

df= df[df['Date'].ge("27-12-2020")]

.ge means greater or equal, so when you put in 26-12-2020 you get both days. Try using .eq instead:

df= df[df['Date'].eq("26-12-2020")]

Upvotes: 1

Related Questions