Computer scienceData scienceInstrumentsPandasStoring data with pandas

Accessing data in a DataFrame

Clever index resetting

Report a typo

You are working with the df_rock that contains sonar signals from two object classes: rocks and mines. In the first four columns, you can see wavelengths that the sonar got from different angles. The last two columns, called name and label respectively, contain an individual object key and the category of an object: rock or mine.

Suppose that after setting the DataFrame index to the name column you've realized that it's quite inconvenient. Your task is to reset indexes and drop the name column. You can complete both tasks by using just one function.

You can see a dataset sample below. Note that df_rock is a variable name that contains the whole DataFrame. Just insert your code before the print() function.

Sample Input 1:

	    zero_deg    sixty_deg	ninety_deg	straight_angle	label
name					
EAO2	0.437427	0.127416	0.258251	0.425674	Mine
PD38	0.421407	0.439730	0.560459	0.424267	Mine
JL46	0.205278	0.434688	0.398431	0.532222	Rock
M7V9	0.094910	0.132226	0.105227	0.156142	Rock
PIYW	0.314031	0.272306	0.057900	0.486960	Rock

Sample Output 1:

RangeIndex(start=0, stop=5, step=1)
Write a program in Python 3
# your code here, the dataset is already loaded. The variable name is df_rock.
...

print(df_rock.index)
___

Create a free account to access the full topic