Skip to content

Commit 59f41ff

Browse files
committed
doc edits
1 parent 2837ebd commit 59f41ff

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

doc/source/dsintro.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ constructed from the sorted keys of the dict, if possible.
9595

9696
NaN (not a number) is the standard missing data marker used in pandas.
9797

98-
**From scalar value**
98+
**From scalar value**
9999

100100
If ``data`` is a scalar value, an index must be
101101
provided. The value will be repeated to match the length of **index**.
@@ -154,7 +154,7 @@ See also the :ref:`section on attribute access<indexing.attribute_access>`.
154154
Vectorized operations and label alignment with Series
155155
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156156

157-
When working with raw NumPy arrays, looping through value-by-value is usually
157+
When working with raw NumPy arrays, looping through value-by-value is usually
158158
not necessary. The same is true when working with Series in pandas.
159159
Series can also be passed into most NumPy methods expecting an ndarray.
160160

@@ -324,7 +324,7 @@ From a list of dicts
324324
From a dict of tuples
325325
~~~~~~~~~~~~~~~~~~~~~
326326

327-
You can automatically create a multi-indexed frame by passing a tuples
327+
You can automatically create a multi-indexed frame by passing a tuples
328328
dictionary.
329329

330330
.. ipython:: python
@@ -347,7 +347,7 @@ column name provided).
347347
**Missing Data**
348348

349349
Much more will be said on this topic in the :ref:`Missing data <missing_data>`
350-
section. To construct a DataFrame with missing data, we use ``np.nan`` to
350+
section. To construct a DataFrame with missing data, we use ``np.nan`` to
351351
represent missing values. Alternatively, you may pass a ``numpy.MaskedArray``
352352
as the data argument to the DataFrame constructor, and its masked entries will
353353
be considered missing.
@@ -370,7 +370,7 @@ set to ``'index'`` in order to use the dict keys as row labels.
370370

371371
``DataFrame.from_records`` takes a list of tuples or an ndarray with structured
372372
dtype. It works analogously to the normal ``DataFrame`` constructor, except that
373-
the resulting DataFrame index may be a specific field of the structured
373+
the resulting DataFrame index may be a specific field of the structured
374374
dtype. For example:
375375

376376
.. ipython:: python
@@ -506,20 +506,21 @@ to be inserted (for example, a ``Series`` or NumPy array), or a function
506506
of one argument to be called on the ``DataFrame``. A *copy* of the original
507507
DataFrame is returned, with the new values inserted.
508508

509-
.. warning::
510-
Starting from Python 3.6 ``**kwargs`` is an ordered dictionary and :func:`DataFrame.assign`
511-
respects the order of the keyword arguments. You may now use assign in the following way:
509+
Starting from Python 3.6 ``**kwargs`` is an ordered dictionary and :func:`DataFrame.assign`
510+
respects the order of the keyword arguments. You can use assign in the following way:
511+
512+
.. ipython:: python
512513
513-
.. ipython:: python
514+
dfa = pd.DataFrame({"A": [1, 2, 3],
515+
"B": [4, 5, 6]})
516+
dfa.assign(C=lambda x: x['A'] + x['B'],
517+
D=lambda x: x['A'] + x['C'])
514518
515-
df_warn = pd.DataFrame({"A": [1, 2, 3],
516-
"B": [4, 5, 6]})
517-
df_warn.assign(C=lambda x: x['A'] + x['B'],
518-
D=lambda x: x['A'] + x['C'])
519+
.. warning::
519520

520-
This may subtly change the behavior of your code when you're
521-
using :func:`DataFrame.assign` to update an existing column. Prior to Python 3.6,
522-
callables referring to other variables being updated would get the "old" values
521+
This may subtly change the behavior of your code when you are
522+
using :func:`DataFrame.assign` to update an existing column. Prior to Python 3.6,
523+
callables referring to other variables being updated would get the "old" values.
523524

524525
Indexing / Selection
525526
~~~~~~~~~~~~~~~~~~~~
@@ -909,7 +910,7 @@ For example, using the earlier example data, we could do:
909910
Squeezing
910911
~~~~~~~~~
911912

912-
Another way to change the dimensionality of an object is to ``squeeze`` a 1-len
913+
Another way to change the dimensionality of an object is to ``squeeze`` a 1-len
913914
object, similar to ``wp['Item1']``.
914915

915916
.. ipython:: python

doc/source/whatsnew/v0.23.0.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ Please note that the string `index` is not supported with the round trip format,
182182
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183183

184184
The :func:`DataFrame.assign` now accepts dependent keyword arguments for python version later than 3.6 (see also `PEP 468
185-
<https://www.python.org/dev/peps/pep-0468/>`_). Later keyword arguments may now refer to earlier ones if the argument is a callable. (:issue:`14207`)
185+
<https://www.python.org/dev/peps/pep-0468/>`_). Later keyword arguments may now refer to earlier ones if the argument is a callable. See the
186+
:ref:`documentation here <dsintro.chained_assignment>` (:issue:`14207`)
186187

187-
.. ipython:: python
188+
.. ipython:: python
188189

189190
df = pd.DataFrame({'A': [1, 2, 3]})
190191
df

0 commit comments

Comments
 (0)