0
$\begingroup$

I'm new to Python for starters, when I got this DataFrame from Yahoo Finance, the Date shows up outside the DataFrame. This is leading me to get KeyError: 'Date' when I try to write this line of code

Close_Price['Year'] = Close_Price['Date'].dt.year

Any ideas on how to fix this?

$\endgroup$
1

1 Answer 1

0
$\begingroup$

I think because the Date column is the index column, maybe you should convert it into normal column like in this question

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.