You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The attribute will not be available if it conflicts with an existing method name, e.g. ``s.min`` is not allowed.
213
+
- The attribute will not be available if it conflicts with an existing method name, e.g. ``s.min`` is not allowed, but ``s['min']``is possible.
214
214
215
215
- Similarly, the attribute will not be available if it conflicts with any of the following list: ``index``,
216
216
``major_axis``, ``minor_axis``, ``items``.
@@ -236,7 +236,7 @@ new column. In 0.21.0 and later, this will raise a ``UserWarning``:
236
236
.. code-block:: ipython
237
237
238
238
In [1]: df = pd.DataFrame({'one': [1., 2., 3.]})
239
-
In [2]: df['two'] = [4, 5, 6]
239
+
In [2]: df.two = [4, 5, 6]
240
240
UserWarning: Pandas doesn't allow Series to be assigned into nonexistent columns - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute_access
241
241
In [3]: df
242
242
Out[3]:
@@ -552,7 +552,7 @@ You can use callable indexing in ``Series``.
552
552
553
553
.. ipython:: python
554
554
555
-
df1.A.loc[lambdas: s >0]
555
+
df1['A']loc[lambdas: s >0]
556
556
557
557
Using these methods / indexers, you can chain data selection operations
558
558
without using a temporary variable.
@@ -1352,7 +1352,7 @@ You can negate boolean expressions with the word ``not`` or the ``~`` operator.
1352
1352
df['bools'] = np.random.rand(len(df)) >0.5
1353
1353
df.query('~bools')
1354
1354
df.query('not bools')
1355
-
df.query('not bools') == df[~df.bools]
1355
+
df.query('not bools') == df[~df['bools']]
1356
1356
1357
1357
Of course, expressions can be arbitrarily complex too:
1358
1358
@@ -1362,7 +1362,7 @@ Of course, expressions can be arbitrarily complex too:
1362
1362
shorter = df.query('a < b < c and (not bools) or bools > 2')
0 commit comments