Skip to content

Commit 73af8d9

Browse files
committed
DOC: add find and replace example to spreadsheet comparison
1 parent 9b16b1e commit 73af8d9

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

doc/source/getting_started/comparison/comparison_with_spreadsheets.rst

+17-4
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,21 @@ NOTE: If the index already exists, the values in that index will be over written
246246
df1
247247
248248
249-
Search and Replace
250-
~~~~~~~~~~~~~~~~~~
249+
Find and Replace
250+
~~~~~~~~~~~~~~~~
251251

252-
The ``replace`` method that comes associated with the ``DataFrame`` object can perform
253-
this function. Please see `pandas.DataFrame.replace <https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html>`__ for examples.
252+
`Excel's Find dialog <https://support.microsoft.com/en-us/office/find-or-replace-text-and-numbers-on-a-worksheet-0e304ca5-ecef-4808-b90f-fdb42f892e90>`_
253+
takes you to cells that match, one by one. In pandas, this operation is generally done for an
254+
entire column or ``DataFrame`` at once through :ref:`conditional expressions <10min_tut_03_subset.rows_and_columns>`.
255+
256+
.. ipython:: python
257+
258+
tips
259+
tips == "Sun"
260+
tips["day"].str.contains("S")
261+
262+
pandas' :meth:`~DataFrame.replace` is comparable to Excel's ``Replace All``.
263+
264+
.. ipython:: python
265+
266+
tips.replace("Thur", "Thu")

doc/source/getting_started/intro_tutorials/03_subset_data.rst

+2
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ For more dedicated functions on missing values, see the user guide section about
268268

269269
</div>
270270

271+
.. _10min_tut_03_subset.rows_and_columns:
272+
271273
How do I select specific rows and columns from a ``DataFrame``?
272274
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273275

0 commit comments

Comments
 (0)