0

I am using Nsepy to retrieve the stock data. when I type the stock symbol , I am getting the whole table but I have no idea how to put the data in csv file.Please help

Holger Just
  • 45,586
  • 14
  • 98
  • 114
Quantum Dreamer
  • 373
  • 1
  • 4
  • 14

2 Answers2

1

You can save the pandas dataframe using pandas.DataFrame.to_csv(file_name='out.csv'). More details here

Community
  • 1
  • 1
swapnil jariwala
  • 856
  • 1
  • 10
  • 17
0
In[6]: nifty_fut
Out[6]: 
           Symbol      Expiry     Open    High      Low    Close     Last  
Date                                                                        
2015-01-01  NIFTY  2015-01-29  8320.00  8356.0  8295.20  8343.80  8347.05   
2015-01-02  NIFTY  2015-01-29  8352.25  8470.9  8352.25  8458.40  8468.00   
2015-01-05  NIFTY  2015-01-29  8452.35  8492.0  8406.00  8422.85  8423.85   
2015-01-06  NIFTY  2015-01-29  8422.00  8422.0  8000.00  8157.90  8150.30   
2015-01-07  NIFTY  2015-01-29  8150.00  8184.0  8096.00  8141.85  8154.00   
2015-01-08  NIFTY  2015-01-29  8209.00  8274.9  8193.10  8257.25  8255.00   
2015-01-09  NIFTY  2015-01-29  8306.35  8334.0  8205.00  8315.50  8311.60  

Save this data as a .CSV file.

niftyfut.to_csv('niftyfut.csv', index = False, header =  None)                
# indexing False

niftyfut.to_csv('niftyfut.csv',index = True , header = None )                
indexing True

And the data will be saved to your working directory.

sɐunıɔןɐqɐp
  • 2,609
  • 15
  • 30
  • 36