I have downloaded some share price data via an API (from Alphavantage):
response = requests.get("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=XXX")
data = response.json()
df = pd.DataFrame.from_dict(data["Time Series (Daily)"], orient='index')
and converted columns to numeric (df.apply(pd.to_numeric))
This is output in Jupyter - very standard matrix of dates and share prices.
I can't figure out how to manipulate the data (such as multiply df.loc[df['1. open'] > 93, '1. open'] *= 2) which is normally easy. I think there is something wrong with the index data. I have tried df.index = pd.to_datetime(df.index) to get it to timedate format and also tried renaming index. Also, the index column doesn't download if I try to move data frame into a csv file.
I think the issue is that the index data is still a string, but don't understand why it doesn't become datetime with code above.
Error message I get is ('>' not supported between instances of 'str' and 'int') but solutions from other questions don't work either.
Sorry for my long winded question and many thanks for any help!
pd.to_datetimecan often fail silently