If you are familiar with lists in Python, the pop() method will ring a bell. The pop() method in series and DataFrames behaves exactly the same as it does with lists. It helps remove entire columns from DataFrames or specific rows from series. Upon being called, the pop() method returns the popped out entity (row or column).
The following snippet demonstrates the use of pop() with a series. Let's pop the item with row index 2 from the "Wins" column:
In: sample_df["Wins"].pop(2)
Out: 26
Now, let's print the Wins series:
It can be seen that index 2 is no longer present in the series. The same method can be applied to a DataFrame as well. Let's pop the Nominations column to understand this:
sample_df.pop("Nominations")
The following is the output:
The following command is used to show the DataFrame result after popping:
sample_df
The following is the output: