I want it to get the index from 0 to 18 instead of typing it out manually. I tried using this but i got a syntax error.
dep=dep.iloc[:,[0:18]]
this is the full code below
dep=df.groupby(['Serious,Critical','ActiveCases','TotalTests','TotalCases','TotalDeaths','TotalRecovered','NewCases','NewDeaths','NewRecovered','New Cases/1M pop','New Deaths/1M pop','Active Cases/1M pop','1 Deathevery X ppl','1 Testevery X ppl','1 Caseevery X ppl']).count()
dep=dep.reset_index()
dep=dep.iloc[:,[0:18]]
dep.head()
CodePudding user response:
The syntax is without brackets:
dep.iloc[:,0:18]
Or, if you want to include 18:
dep.iloc[:,0:18 1]
Brackets would be used to pass a list of columns to index. For instance dep.iloc[:,[0,18]]
would take columns 0
and 18
but not those in between.