How to get DATE column from dataframe in pandas without using CSV This is my code.
import pandas as pd
import pandas_datareader.data as web
import datetime as dt

start = dt.datetime(2019, 2, 1)
end = datetime.today().strftime('%Y-%m-%d')
slug = &quot;tsla&quot;
df = web.DataReader(slug, 'yahoo', start, end)

print(df)

This prints this ---&gt;
                  High         Low        Open       Close      Volume   Adj Close
Date
2019-01-31   62.312000   58.799999   60.200001   61.403999  62846000.0   61.403999
2019-02-01   63.220001   60.700001   61.084000   62.442001  36417000.0   62.442001
2019-02-04   63.060001   60.375999   62.596001   62.577999  36760500.0   62.577999
2019-02-05   64.487999   62.450001   62.498001   64.269997  33714000.0   64.269997
2019-02-06   64.848000   63.124001   63.917999   63.444000  25192500.0   63.444000
...                ...         ...         ...         ...         ...         ...
2020-10-12  448.739990  438.579987  442.000000  442.299988  38791100.0  442.299988
2020-10-13  448.890015  436.600006  443.350006  446.649994  34463700.0  446.649994
2020-10-14  465.899994  447.350006  449.779999  461.299988  48045400.0  461.299988
2020-10-15  456.570007  442.500000  450.309998  448.880005  35672400.0  448.880005
2020-10-16  455.950012  438.850006  454.440002  439.670013  32620000.0  439.670013

[433 rows x 6 columns]

I only want to get this Date column from df,
If i write

df['Date']

it gives me error, but if i use CSV file, then everything works fine
df.to_csv('%s.csv' % slug)
df = pd.read_csv('%s.csv' % slug)

but it creates so much csv files for every company, so i want to use it without CSV
You need to reset index using df.reset_index().This will make your Dates attribute/column and not an index as it is now.
import pandas as pd
import pandas_datareader.data as web
import datetime as dt

start = dt.datetime(2019, 2, 1)
end = dt.datetime.today().strftime('%Y-%m-%d')
slug = &quot;tsla&quot;
df = web.DataReader(slug, 'yahoo', start, end)
modified = df.reset_index()
print(modified['Date'])