how to get stock data in a csv files

Solutions on MaxInterview for how to get stock data in a csv files by the best coders in the world

showing results for - "how to get stock data in a csv files"
Laura
04 Jul 2019
1#import external pandas_datareader library with alias of web
2import pandas_datareader as web
3 
4#import datetime internal datetime module
5#datetime is a Python module
6import datetime
7 
8#datetime.datetime is a data type within the datetime module
9start = datetime.datetime(2017, 9, 1)
10end = datetime.datetime(2017, 12, 31)
11 
12#DataReader method name is case sensitive
13df = web.DataReader("nvda", 'yahoo', start, end)
14 
15#invoke to_csv for df dataframe object from 
16#DataReader method in the pandas_datareader library
17 
18#..\first_yahoo_prices_to_csv_demo.csv must not
19#be open in another app, such as Excel
20 
21df.to_csv('first_yahoo_prices_volumes_to_csv_demo.csv')
22