Transform dataframe to dict
Tags: #pandas #dict #snippet #yahoofinance #naas_drivers #operations #jupyternotebooks
Description: This notebook provides an example of how to use the Pandas library to convert a dataframe into a dictionary.
from naas_drivers import yahoofinance
👉 Here you can change the ticker, timeframe and add moving averages analysis
ticker = "TSLA"
date_from = -100
date_to = "today"
df_yahoo = yahoofinance.get(ticker, date_from=-5)
df_yahoo
Params = orient
- list: keys are column names, values are lists of column data
- records: each row becomes a dictionary where key is column name and value is the data in the cell
dict_yahoo = df_yahoo.to_dict(orient="records")
dict_yahoo
Last modified 1mo ago