I'm am using ipython widgets so unsure why this error is occurring
Using @interact and a list of strings as an input to the function below:
@wdg.interact(lines=["Number of cases", "Number of admissions", "Number of deaths"])
def time_series_graph( lines):
n_lines=len(lines)
if n_lines>0:
data[list(lines)].plot()
else:
print("Select the data you want to print.")
I already have a pandas data frame with the column names as in the list lines but this code does not work. The list of strings is split up so that each letter is a member of the list.
This (among others) is the error shown:
KeyError: "None of [Index(['N', 'u', 'm', 'b', 'e', 'r', ' ', 'o', 'f', ' ', 'c', 'a', 's', 'e',\n 's'],\n dtype='object')] are in the [columns]"
What is the reason for this and any idea how to fix it?
Thanks for your help!