Skip to content

Commit 1917db1

Browse files
committed
DOC: update example for adding rows in spreadsheet comparison
Old example was referencing a no-longer-existent variable. Switched to use `append()` rather than `loc`.
1 parent 973f7a8 commit 1917db1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

doc/source/getting_started/comparison/comparison_with_spreadsheets.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,13 @@ The equivalent in pandas:
416416
Adding a row
417417
~~~~~~~~~~~~
418418

419-
To appended a row, we can just assign values to an index using :meth:`~DataFrame.loc`.
420-
421-
NOTE: If the index already exists, the values in that index will be over written.
419+
Assuming we are using a :class:`~pandas.RangeIndex` (numbered ``0``, ``1``, etc.), we can use :meth:`DataFrame.append` to add a row to the bottom of a ``DataFrame``.
422420

423421
.. ipython:: python
424422
425-
df1.loc[7] = [8, "tonks"]
426-
df1
423+
df
424+
new_row = {"class": "E", "student_count": 51, "all_pass": True}
425+
df.append(new_row, ignore_index=True)
427426
428427
429428
Find and Replace

0 commit comments

Comments
 (0)