Computer scienceData scienceInstrumentsPandasData preprocessing with pandas

Modifying a DataFrame

Delete repeating penguin

Report a typo

Imagine that you are working with the penguin DataFrame penguins_example. You can see it below.

As you might have noticed, the last two rows of penguins_example are identical. Your task is to delete the last row to avoid repetitions.

Note that the DataFrame is already stored in the variable penguins_example, so you just need to insert your code before the print() function. You don't need to import pandas here.

Sample Input 1:

        species	    bill_length_mm	bill_depth_mm
1	Adelie	        41.1	    18.2
2	Adelie	        39.6	    17.7
3	Chinstrap	50.0	    19.5
4	Chinstrap	54.2	    20.8
5	Gentoo	        41.7	    14.7
6	Gentoo	        45.5	    13.9
7	Gentoo	        45.5	    13.9

Sample Output 1:

     species  bill_length_mm  bill_depth_mm
1     Adelie            41.1           18.2
2     Adelie            39.6           17.7
3  Chinstrap            50.0           19.5
4  Chinstrap            54.2           20.8
5     Gentoo            41.7           14.7
6     Gentoo            45.5           13.9
Write a program in Python 3
# Your code here.
# The dataset is already loaded, the variable that contains the DataFrame is called penguins_example

print(penguins_example)
___

Create a free account to access the full topic