0

I am not able to get this date column which is visible in the below given image.enter image description here

I want to store this date in another dataframe

I have tried this:

sbin['Date']

but its not working

complete code:

from datetime import date
import datetime
from nsepy import get_history
import pandas as pd

enddate = datetime.datetime.today()
startdate = enddate - datetime.timedelta(10)
sbin = get_history(symbol='SBIN',
                   start=startdate,
                   end=enddate)
print(type(sbin))
sbin
Akshay
  • 1,019
  • 12
  • 21

2 Answers2

1

#You are trying to access pandas.core.internals.BlockManager. So in order to get date you need to get the block manager first and then get the axis :

Bm = sbin._data
date_time = Bm.axes[1] 
print(date_time)
#if you want to access individual element access like a list
date_time[0]

Hope this helps you.

1

Try this:

from nsepy import get_history
from datetime import date
data = get_history(symbol="SBIN", start=date(2015,1,1), end=date(2015,1,31))
data[['Close']].plot()

ref: https://nsepy.xyz/

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
GS Singh
  • 11
  • 1