Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 421 Bytes

File metadata and controls

21 lines (14 loc) · 421 Bytes
orphan:

The same operation in pandas can be accomplished using the where method from numpy.

.. ipython:: python
   :suppress:

   # ensure tips is defined when scanning with flake8-rst
   if 'tips' not in vars():
       tips = {}

.. ipython:: python

   tips["bucket"] = np.where(tips["total_bill"] < 10, "low", "high")
   tips.head()

.. ipython:: python
   :suppress:

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