Currently I have achieved the title by using .apply() with a lambda function:
calFilteredDf['startTime'] = calFilteredDf['start'].apply(lambda x: x['dateTime'])
This is very slow and I was wondering how I could achieve the same results in less time. calFilteredDf['start'] is a Pandas Series and the data from the 'start' column looks like this:
1 {'date': None, 'dateTime': '2021-08-11T15:00:0...
2 {'date': None, 'dateTime': '2021-08-12T09:30:0...
3 {'date': None, 'dateTime': '2021-08-12T10:00:0...
4 {'date': None, 'dateTime': '2021-08-18T11:00:0...
...
1692 {'date': None, 'dateTime': '2023-08-09T14:00:0...
1693 {'date': None, 'dateTime': '2023-08-09T15:00:0...
1694 {'date': None, 'dateTime': '2023-08-10T11:30:0...
1695 {'date': None, 'dateTime': '2023-08-10T16:00:0...
1696 {'date': None, 'dateTime': '2023-08-10T17:00:0...
Name: start, Length: 1697, dtype: object
and the data from the new 'startTime' column needs to look like this:
1 2021-08-11T15:00:00-04:00
2 2021-08-12T09:30:00-04:00
3 2021-08-12T10:00:00-04:00
4 2021-08-18T11:00:00-04:00
...
1692 2023-08-09T14:00:00-04:00
1693 2023-08-09T15:00:00-04:00
1694 2023-08-10T11:30:00-04:00
1695 2023-08-10T16:00:00-04:00
1696 2023-08-10T17:00:00-04:00
Name: startTime, Length: 1697, dtype: object
Is there a way to do this quickly? I have tried to set
calFilteredDf['startTime'] = calFilteredDf['startTime']['dateTime']
I've also tried using .loc which didn't work because the rows of 'start' aren't the right data type and I've tried using the swifter library to parallelize the process that .apply() is doing but since the dataset is not very large it actually made it slower because of the extra steps the library preforms to determine what the best way to process the data is.