def handle_data(symbol, start, end): stock_data = data.DataReader( symbol, 'yahoo', start, end) return stock_data x = handle_data(ticker, start=datetime(2021, 1, 2), end=datetime(2021, 2, 5)) This function returns this:
High Low Open Close Volume \ Date 2021-02-02 136.309998 134.610001 135.729996 134.990005 83305400 2021-02-03 135.770004 133.610001 135.759995 133.940002 89880900 2021-02-04 137.399994 134.589996 136.300003 137.389999 83946000 2021-02-05 137.410004 135.860001 137.350006 136.759995 72317009 I want to make it so my python script can save stock historical data into a csv file so I can use it for later projects. I tried doing this with the csv module, but couldn't find anything that matches with what i am trying to do. Is there any way of storing this data into a new csv file without needing an existing one.