KeyError: "None of [Index(['Date', 'VOLUME'], dtype='object')] are in the [columns]"

Course Name: Python for Trading: Basic, Section No: 5, Unit No: 15, Unit type: Notebook


Preparing Data to visualise


infy_close = infy [['Date','VOLUME']] # The columns which we require 
infy_close.set_index('Date', inplace=True) # Setting index as date
# More on this in the upcoming section on 'Pandas'
infy_close

gives below error
KeyError: "None of [Index(['Date', 'VOLUME'], dtype='object')] are in the [columns]"
infy dataframe have below columns
infy.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 252 entries, 0 to 251
Data columns (total 14 columns):
 #   Column         Non-Null Count  Dtype  
---  ------         --------------  -----  
 0   Date           252 non-null    object 
 1   series         252 non-null    object 
 2   OPEN           252 non-null    object 
 3   HIGH           252 non-null    object 
 4   LOW            252 non-null    object 
 5   PREV. CLOSE    252 non-null    object 
 6   ltp            252 non-null    object 
 7   close          252 non-null    object 
 8   vwap           252 non-null    object 
 9   52W H          252 non-null    object 
 10  52W L          252 non-null    float64
 11  VOLUME         252 non-null    int64  
 12  VALUE          252 non-null    object 

 

Hi Suresh,



It seems you are working with custom data (since Volume was not in the original data frame).



Please share your data files along with the jupyter notebook(.ipynb) here so we can assist you further.



Thanks!