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$
1
  • $\begingroup$ Thank you so much $\endgroup$ Nov 28, 2021 at 4:05

Your Answer

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

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