Question: I have used pandas dataframe to read the data from an Excel file in Python. From the Excel file, I have read the date column

I have used pandas dataframe to read the data from an Excel file in Python. From the Excel file, I have read the date column and changed the format of the date to yyyymmdd using the code below.

import datetime

import pandas as pd

excel_data_df = pd.read_excel('Charting.xls', sheet_name='Worksheet')

X = pd.to_datetime(excel_data_df["Date"]).dt.strftime("%Y%m%d")

print (X)

This gives me the output with an ID number and the date.

0 20200117

1 20200121

2 20200122

3. 20200123

4 20200124

...

247 20210111

248. 20210112

249 20210113

250 20210114

251 20210115

I need to take the date value from each row and subtract 19000000 from the date value in each row of the output. For example for ID 0 I need 20200117-19000000 = 1200117. How can I do this?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!