I currently have a dataframe which include a column called timeAccepted
.
I'm trying to print the value of timeAccepted
for every iteration. I'm simply using the following code:
def print_time(df):
print(df['timeAccepted'])
for i, row in df.iterrows():
print(df.columns)
print(df.at[i, 'timeAccepted'])
But I'm getting the following error:
KeyError: 'timeAccepted'
please note that print(df['timeAccepted'])
have as an output:
0 2023-07-27T06:50:03.747135Z
1 2023-07-27T06:50:06.030559Z
2 2023-07-27T06:50:08.025268Z
3 2023-07-27T06:50:10.024531Z
4 2023-07-27T06:50:12.028957Z
...
26232 2023-07-27T12:46:27.024663Z
26233 2023-07-27T12:46:27.024663Z
26234 2023-07-27T12:45:02.027558Z
26235 2023-07-27T12:46:29.023594Z
26236 2023-07-27T12:46:29.023594Z
Name: timeAccepted, Length: 26237, dtype: object
and print(df.columns)
:
Index(['Order identification code', 'Initial quantity', 'side', 'Order type',
'timeInForce', 'Limit price', 'quoteId', 'userId', 'timeAccepted'], dtype='object')
So, I've checked and the column do exist in the dataframe but I'm still having the KeyError! Please help!