Back to Pandas

Keep certain columns

doc/source/getting_started/comparison/includes/column_selection.rst

3.1.0.dev0342 B
Original Source

The same operations are expressed in pandas below.

Keep certain columns ''''''''''''''''''''

.. ipython:: python

tips[["sex", "total_bill", "tip"]]

Drop a column '''''''''''''

.. ipython:: python

tips.drop("sex", axis=1)

Rename a column '''''''''''''''

.. ipython:: python

tips.rename(columns={"total_bill": "total_bill_2"})