Computer scienceData scienceInstrumentsPandasData analysis with pandas

Reshaping and Pivot Tables

Mean

Report a typo

Please note: for now, when you go to the tab IDE, you can solve this problem only via Pycharm. We are sorry for the inconvenience, we will fix this as soon as we can. If you prefer to solve the problem via a different IDE, you should open it manually and then copy the solution to the website.

You are working with a DataFrame df_rock that contains sonar signals. There are two types of signals - the ones from mines and the others from rocks. The first five columns contain waves lengths that got a sonar from different angles.

1. Load the data from the .txt file as Pandas DataFrame.

2. Calculate mean values for all columns grouped by the label (don't forget about our old friend - pivot_table ).

3. Round the mean value for rocks from null_deg column to two decimal places and insert it in the answer field.

Sample Input 1:

,null_deg,60_deg,90_deg,180_deg,240_deg,labels
0,0.740204,0.981484,0.605161,0.67712,0.55432,R
1,0.788051,0.68378,0.504151,0.713523,0.690165,M
2,0.6373,0.668011,0.35894,0.804288,0.713663,M
3,0.560475,0.487072,0.103085,0.668011,0.805988,R

Sample Output 1:

0.65
Write code in your IDE to process the text file and display the results below
___

Create a free account to access the full topic