Вопрос

I used the below code for downloading stock data from yahoo finance:-

import yfinance as yf
import datetime

    stocks = ["AXISBANK.NS", "HDFCBANK.NS", "ICICIBANK.NS" ,"INDUSINDBK.NS",
    "KOTAKBANK.NS",
    "SBIN.NS",
    "YESBANK.NS"]
    start = datetime.datetime(2018,1,1)
    end = datetime.datetime(2019,7,17)
    data = yf.download(stocks, start=start, end=end)
    data

I get the data in a below manner:-

enter image description here

I saved the data using panda:-

import pandas as pd

df = pd.DataFrame(data) 

# saving the dataframe 
df.to_csv('BANKING STOCK.csv')

I got the data in this format:- enter image description here

But I ant my data in this format:-

enter image description here

Because this format is more convenient for analyzing data through SQL. How can I change the format of the data?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с datascience.stackexchange
scroll top