Skip to content

Commit 75056a2

Browse files
author
MarcoGorelli
committed
[skip ci] reword, reformat
1 parent 997d601 commit 75056a2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

web/pandas/pdeps/0005-no-default-index-mode.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ step towards enabling users who do not want to think about indices to not need t
1717
The Index can be a source of confusion and frustration for pandas users. For example, let's consider the inputs
1818

1919
```python
20-
In [37]: ser1 = pd.Series([10, 15, 20, 25], index=[1, 2, 3, 5])
20+
In[37]: ser1 = pd.Series([10, 15, 20, 25], index=[1, 2, 3, 5])
2121

22-
In [38]: ser2 = pd.Series([10, 15, 20, 25], index=[1, 2, 3, 4])
22+
In[38]: ser2 = pd.Series([10, 15, 20, 25], index=[1, 2, 3, 4])
2323
```
2424

2525
Then:
@@ -200,7 +200,7 @@ TypeError: Cannot join NoRowIndex of different lengths
200200

201201
### Columns cannot be NoRowIndex
202202

203-
This proposal deals exclusively with letting users not have to think about
203+
This proposal deals exclusively with allowing users to not have to think about
204204
row labels. There's no suggestion to remove the column labels.
205205

206206
In particular, calling ``transpose`` on a ``NoRowIndex`` ``DataFrame``
@@ -241,13 +241,13 @@ function to return a ``NoRowIndex`` rather than a ``RangeIndex``.
241241
Then, if a user opted in to this mode with
242242

243243
```python
244-
pd.set_option('mode.no_row_index', True)
244+
pd.set_option("mode.no_row_index", True)
245245
```
246246

247247
then the following would all create a ``DataFrame`` with a ``NoRowIndex`` (as they
248248
all call ``default_index``):
249249

250-
- ``df.reset_index(drop=True)``;
250+
- ``df.reset_index()``;
251251
- ``pd.concat([df1, df2], ignore_index=True)``
252252
- ``df1.merge(df2, on=col)``;
253253
- ``df = pd.DataFrame({'col_1': [1, 2, 3]})``
@@ -270,19 +270,19 @@ accepted. For example, ``NoRowIndex`` would not necessarily need to subclass
270270

271271
**A**: ``RangeIndex`` is not preserved under slicing and appending, e.g.:
272272
```python
273-
In [1]: ser = pd.Series([1,2,3])
273+
In[1]: ser = pd.Series([1, 2, 3])
274274

275-
In [2]: ser[ser!=2].index
276-
Out[2]: Int64Index([0, 2], dtype='int64')
275+
In[2]: ser[ser != 2].index
276+
Out[2]: Int64Index([0, 2], dtype="int64")
277277
```
278278
If someone does not want to think about row labels and starts off
279279
with a ``RangeIndex``, they'll very quickly lose it.
280280

281281
**Q: Are indices not really powerful?**
282282

283283
**A:** Yes! And they're also confusing to many users, even experienced developers.
284-
It's fairly common to see pandas code with ``.reset_index`` scattered around every
285-
other line. Such users would benefit from being able to not think about indices
284+
Often users are using ``.reset_index`` to avoid issues with indices and alignment.
285+
Such users would benefit from being able to not think about indices
286286
and alignment. Indices would be here to stay, and ``NoRowIndex`` would not be the
287287
default.
288288

@@ -331,16 +331,16 @@ accepted. For example, ``NoRowIndex`` would not necessarily need to subclass
331331
**Q: Would ``.loc`` stop working?**
332332

333333
**A:** No. It would only raise if used for label-based selection. Other uses
334-
of ``.loc``, such as ``df.loc[:, col_1]`` or ``df.loc[mask, col_1]``, would
334+
of ``.loc``, such as ``df.loc[:, col_1]`` or ``df.loc[boolean_mask, col_1]``, would
335335
continue working.
336336

337337
**Q: What's unintuitive about ``Series`` aligning indices when summing?**
338338

339339
**A:** Not sure, but I once asked a group of experienced developers what the
340340
output of
341341
```python
342-
ser1 = pd.Series([1,1,1], index=[1,2,3])
343-
ser2 = pd.Series([1,1,1], index=[3,4,5])
342+
ser1 = pd.Series([1, 1, 1], index=[1, 2, 3])
343+
ser2 = pd.Series([1, 1, 1], index=[3, 4, 5])
344344
print(ser1 + ser2)
345345
```
346346
would be, and _nobody_ got it right.

0 commit comments

Comments
 (0)