Computer scienceData scienceInstrumentsPandasData analysis with pandas

Summarizing categorical columns

Non-NA values

Report a typo

You are working with a DataFrame called df_rock that contains sonar signals from two object classes: rocks and mines. In the first five columns, you can see the wavelengths that the sonar got from different angles.

Load the given data as a pandas Data Frame, then check how many non-NA values the "labels" column has. You can use .count() for that.

Tip: The .loc method can help you select the required column.

Sample Input 1:

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

Sample Output 1:

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

Create a free account to access the full topic