In python 3.9, I have declared the following python DataFrame, raw
>>> print(raw)
Date AAPL.O MSFT.O INTC.O AMZN.O GS.N SPY \
1 2010-01-04 30.572827 30.950 20.88 133.90 173.08 113.33
...
from which I would like to extract one column (e.g. AAPL.O) and the corresponding Date (as index)
I thought that a possible way would be
raw2=pandas.DataFrame(data=raw['AAPL.O'], index=raw['Date'])
This doesn't return any error, however, when I print it, I get:
Date AAPL.O
2010-01-04 NaN
2010-01-05 NaN
...
If I remove index=raw['Date'] from the declaration
raw2=pandas.DataFrame(data=raw['AAPL.O'])
it works as expected (except for the fact that I don't have the index that I wanted).
So I don't understand why but passing a column of the former dataframe (as data) and another column as index, brings me these unexpected NaN.
While there are better ways to achieve my goal, I expected this one to work as well. So probably I am missing something more fundamental which I would like to understand