8
8
9
9
## Abstract
10
10
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.
14
14
15
15
## Motivation
16
16
17
17
The Index can be a source of confusion and frustration for pandas users. For example, let's consider the inputs
18
18
19
19
``` 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 ])
21
21
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 ])
23
23
24
24
Then:
25
25
33
33
3 40.0
34
34
4 NaN
35
35
5 NaN
36
- Name: amount, dtype: float64
36
+ dtype: float64
37
37
```
38
38
39
39
- concatenation, even with ` ignore_index=True ` , still aligns on the index (https://github.com/pandas-dev/pandas/issues/25349 ):
@@ -61,19 +61,20 @@ Then:
61
61
dtype: int64
62
62
```
63
63
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.
65
66
66
67
## Scope
67
68
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
69
70
about row labels, the following could also be useful:
70
71
- a `` pd.set_option('mode.no_default_index') `` mode which would default to creating new `` DataFrame `` s and
71
72
`` Series `` with `` NoRowIndex `` instead of `` RangeIndex `` ;
72
73
- giving `` as_index `` options to methods which currently create an index
73
74
(e.g. `` value_counts `` , `` .sum() `` , `` .pivot_table `` ) to just insert a new column instead of creating an
74
75
`` Index `` .
75
76
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.
77
78
78
79
## Detailed Description
79
80
@@ -83,7 +84,7 @@ in some cases:
83
84
- ` name ` could only be ` None ` ;
84
85
- ` start ` could only be ` 0 ` , ` step ` ` 1 ` ;
85
86
- 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 ;
87
88
- it could only be aligned with another `` Index `` if it's also `` NoRowIndex `` and if it's of the same length;
88
89
- `` DataFrame `` columns can't be ` NoRowIndex ` (so `` transpose `` would need some adjustments when called on a `` NoRowIndex `` `` DataFrame `` );
89
90
- ` 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
124
125
Out[11 ]: NoRowIndex(len = 4 )
125
126
```
126
127
127
- Appending anything other than another `` NoRowIndex `` would raise.
128
+ Appending anything index other than another `` NoRowIndex `` would raise.
128
129
129
130
### Slicing a `` NoRowIndex ``
130
131
@@ -208,7 +209,7 @@ Of the above changes, this may be the only one that would need implementing with
208
209
## Usage and Impact
209
210
210
211
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
212
213
the `` default_index `` function to return a `` NoRowIndex `` of the appropriate length.
213
214
In particular, `` .reset_index() `` would result in a `` DataFrame `` with a `` NoRowIndex `` .
214
215
Likewise, a `` DataFrame `` constructed without explicitly specifying `` index= `` .
0 commit comments