Skip to content

Commit 6b43767

Browse files
author
MarcoGorelli
committed
[skip ci] wip
1 parent 6c15341 commit 6b43767

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
## Abstract
1010

11-
The suggestion is to add a ``NoRowIndex`` class. Internally, it would act like
12-
a ``RangeIndex``, but it would enable users who don't want to think about row
13-
labels to not need to.
11+
The suggestion is to add a ``NoRowIndex`` class. Internally, it would act a bit like
12+
a ``RangeIndex``, but some methods would be stricter. The ultimate objective would be
13+
to enable users who don't want to think about row labels to not need to.
1414

1515
## Motivation
1616

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], name='sender')
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], name='receiver')
22+
In [38]: ser2 = pd.Series([10, 15, 20, 25], index=[1, 2, 3, 4])
2323

2424
Then:
2525

@@ -33,7 +33,7 @@ Then:
3333
3 40.0
3434
4 NaN
3535
5 NaN
36-
Name: amount, dtype: float64
36+
dtype: float64
3737
```
3838

3939
- concatenation, even with `ignore_index=True`, still aligns on the index (https://github.com/pandas-dev/pandas/issues/25349):
@@ -61,19 +61,20 @@ Then:
6161
dtype: int64
6262
```
6363

64-
With ``NoRowIndex`` DataFrames/Series, users who don't want to worry about indices wouldn't need to.
64+
A ``NoRowIndex`` DataFrames/Series would be a first step towards enabling users who
65+
don't want to worry about indices to not need to.
6566

6667
## Scope
6768

68-
This proposal deals exclusively with the ``NoRowIndex``. To allow users to "opt-out" of having to think
69+
This proposal deals exclusively with the ``NoRowIndex`` class. To allow users to "opt-out" of having to think
6970
about row labels, the following could also be useful:
7071
- a ``pd.set_option('mode.no_default_index')`` mode which would default to creating new ``DataFrame``s and
7172
``Series`` with ``NoRowIndex`` instead of ``RangeIndex``;
7273
- giving ``as_index`` options to methods which currently create an index
7374
(e.g. ``value_counts``, ``.sum()``, ``.pivot_table``) to just insert a new column instead of creating an
7475
``Index``.
7576

76-
However, neither of the above will be discussed here. Only the ``NoRowIndex`` object will be discussed here.
77+
However, neither of the above will be discussed here.
7778

7879
## Detailed Description
7980

@@ -83,7 +84,7 @@ in some cases:
8384
- `name` could only be `None`;
8485
- `start` could only be `0`, `step` `1`;
8586
- when appending a ``NoRowIndex``, the result would still be ``NoRowIndex``;
86-
- when slicing, one would still get a `NoRowIndex`;
87+
- the ``NoRowIndex`` class would be preserved under slicing;
8788
- it could only be aligned with another ``Index`` if it's also ``NoRowIndex`` and if it's of the same length;
8889
- ``DataFrame`` columns can't be `NoRowIndex` (so ``transpose`` would need some adjustments when called on a ``NoRowIndex`` ``DataFrame``);
8990
- `insert` and `delete` should raise. As a consequence, if ``df`` is a ``DataFrame`` with a
@@ -124,7 +125,7 @@ In [11]: pd.concat([df, df]).index
124125
Out[11]: NoRowIndex(len=4)
125126
```
126127

127-
Appending anything other than another ``NoRowIndex`` would raise.
128+
Appending anything index other than another ``NoRowIndex`` would raise.
128129

129130
### Slicing a ``NoRowIndex``
130131

@@ -208,7 +209,7 @@ Of the above changes, this may be the only one that would need implementing with
208209
## Usage and Impact
209210

210211
By itself, ``NoRowIndex`` would be of limited use. To become useful and user-friendly,
211-
a mode ``no_default_index`` could be introduced which, if introduced, would change
212+
a mode ``no_default_index`` could be introduced which, if enabled, would change
212213
the ``default_index`` function to return a ``NoRowIndex`` of the appropriate length.
213214
In particular, ``.reset_index()`` would result in a ``DataFrame`` with a ``NoRowIndex``.
214215
Likewise, a ``DataFrame`` constructed without explicitly specifying ``index=``.

0 commit comments

Comments
 (0)