File: column_selection.rst

package info (click to toggle)
pandas 2.2.3%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,784 kB
  • sloc: python: 422,228; ansic: 9,190; sh: 270; xml: 102; makefile: 83
file content (22 lines) | stat: -rw-r--r-- 343 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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"})