A requirement I was given was to change the dates (not times) of a pandas dataframe. However, I am unable to change the dates of the given pandas date column and encountered a few errors
I did some exploring and discovered the ".replace" keyword for pandas. However, when I used that keyword for the following code:
report_time = df['report_time']
report_time.Timestamp.replace(year = 2022, month = 3, day = 21)
And I get the following error:
Traceback (most recent call last):
File "/Users/kenneth/Desktop/hardware_test_harness/readCSV.py", line 20, in <module>
report_time.Timestamp.replace(year = 2022, month = 3, day = 21)
File "/usr/local/lib/python3.9/site-packages/pandas/core/generic.py", line 5583, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'Timestamp'
Here is a screenshot of my pandas dataframe, as well as copy of my code. I'm incredibly lost on what I need to do here to make this a success.
import pandas as pd
import numpy as np
import datetime
from datetime import datetime
from datetime import timedelta
#todo:
#write a script that performs an installation of all the needed files
df = pd.read_csv('event_file.csv')
#5 columns, pandas starts from 0
zone_type = df['zone_type'].to_numpy()
reported_time = df['report_time'].to_numpy()
event_type = df['event_type'].to_numpy()
value = df['value'].to_numpy()
#report_time = df['report_time']
#report_time.Timestamp.replace(year = 2022, month = 3, day = 21)
print(df)