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
- it can be unexpected that summing`Series` with the same length (but different indices) produces `NaN`s in the result (https://stackoverflow.com/q/66094702/4451315):
27
+
- it can be unexpected that adding`Series` with the same length (but different indices) produces `NaN`s in the result (https://stackoverflow.com/q/66094702/4451315):
28
28
29
29
```python
30
30
In [41]: ser1 + ser2
@@ -62,15 +62,15 @@ Then:
62
62
dtype: int64
63
63
```
64
64
65
-
If a user didn't want to think about row labels (which they may have ended up after slicing / concatenating operations),
65
+
If a user did not want to think about row labels (which they may have ended up after slicing / concatenating operations),
66
66
then ``NoRowIndex`` would enable the above to work in a more intuitive
67
67
manner (details and examples to follow below).
68
68
69
69
## Scope
70
70
71
71
This proposal deals exclusively with the ``NoRowIndex`` class. To allow users to fully "opt-out" of having to think
72
72
about row labels, the following could also be useful:
73
-
- a ``pd.set_option('mode.no_default_index')`` mode which would default to creating new ``DataFrame``s and
73
+
- a ``pd.set_option('mode.no_row_index', True)`` mode which would default to creating new ``DataFrame``s and
74
74
``Series`` with ``NoRowIndex`` instead of ``RangeIndex``;
75
75
- giving ``as_index`` options to methods which currently create an index
76
76
(e.g. ``value_counts``, ``.sum()``, ``.pivot_table``) to just insert a new column instead of creating an
@@ -85,17 +85,19 @@ within the ``NoRowIndex`` object. It would act just like ``RangeIndex``, but wou
85
85
in some cases:
86
86
-`name` could only be `None`;
87
87
-`start` could only be `0`, `step``1`;
88
-
- when appending a ``NoRowIndex``, the result would still be ``NoRowIndex``;
88
+
- when appending one ``NoRowIndex`` to another ``NoRowIndex``, the result would still be ``NoRowIndex``.
89
+
Appending a ``NoRowIndex`` to any other index (or vice-versa) would raise;
89
90
- the ``NoRowIndex`` class would be preserved under slicing;
90
-
-it could only be aligned with another ``Index`` if it's also ``NoRowIndex`` and if it's of the same length;
91
-
-``DataFrame`` columns can't be `NoRowIndex` (so ``transpose`` would need some adjustments when called on a ``NoRowIndex````DataFrame``);
91
+
-a ``NoRowIndex`` could only be aligned with another ``Index`` if it's also ``NoRowIndex`` and if it's of the same length;
92
+
-``DataFrame`` columns cannot be `NoRowIndex` (so ``transpose`` would need some adjustments when called on a ``NoRowIndex````DataFrame``);
92
93
-`insert` and `delete` should raise. As a consequence, if ``df`` is a ``DataFrame`` with a
93
94
``NoRowIndex``, then `df.drop` with `axis=0` would always raise;
94
95
- arithmetic operations (e.g. `NoRowIndex(3) + 2`) would always raise;
95
-
- when printing a ``DataFrame``/``Series`` with a ``NoRowIndex``, then the row labels wouldn't be printed;
96
+
- when printing a ``DataFrame``/``Series`` with a ``NoRowIndex``, then the row labels would not be printed;
96
97
- a ``MultiIndex`` could not be created with a ``NoRowIndex`` as one of its levels.
97
98
98
-
Let's go into more detail for some of these.
99
+
Let's go into more detail for some of these. In the examples that follow, the ``NoRowIndex`` will be passed explicitly,
100
+
but this is not how users would be expected to use it (see "Usage and Impact" section for details).
99
101
100
102
### NoRowIndex.append
101
103
@@ -108,16 +110,21 @@ result in a ``DataFrame`` which still has ``NoRowIndex``. To do this, the follow
0 commit comments