@@ -17,9 +17,9 @@ step towards enabling users who do not want to think about indices to not need t
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 ])
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 ])
22
+ In[38 ]: ser2 = pd.Series([10 , 15 , 20 , 25 ], index = [1 , 2 , 3 , 4 ])
23
23
```
24
24
25
25
Then:
@@ -200,7 +200,7 @@ TypeError: Cannot join NoRowIndex of different lengths
200
200
201
201
### Columns cannot be NoRowIndex
202
202
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
204
204
row labels. There's no suggestion to remove the column labels.
205
205
206
206
In particular, calling `` transpose `` on a `` NoRowIndex `` `` DataFrame ``
@@ -241,13 +241,13 @@ function to return a ``NoRowIndex`` rather than a ``RangeIndex``.
241
241
Then, if a user opted in to this mode with
242
242
243
243
``` python
244
- pd.set_option(' mode.no_row_index' , True )
244
+ pd.set_option(" mode.no_row_index" , True )
245
245
```
246
246
247
247
then the following would all create a `` DataFrame `` with a `` NoRowIndex `` (as they
248
248
all call `` default_index `` ):
249
249
250
- - `` df.reset_index(drop=True ) `` ;
250
+ - `` df.reset_index() `` ;
251
251
- `` pd.concat([df1, df2], ignore_index=True) ``
252
252
- `` df1.merge(df2, on=col) `` ;
253
253
- `` df = pd.DataFrame({'col_1': [1, 2, 3]}) ``
@@ -270,19 +270,19 @@ accepted. For example, ``NoRowIndex`` would not necessarily need to subclass
270
270
271
271
** A** : `` RangeIndex `` is not preserved under slicing and appending, e.g.:
272
272
``` python
273
- In [1 ]: ser = pd.Series([1 ,2 , 3 ])
273
+ In[1 ]: ser = pd.Series([1 , 2 , 3 ])
274
274
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" )
277
277
```
278
278
If someone does not want to think about row labels and starts off
279
279
with a `` RangeIndex `` , they'll very quickly lose it.
280
280
281
281
** Q: Are indices not really powerful?**
282
282
283
283
** 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
286
286
and alignment. Indices would be here to stay, and `` NoRowIndex `` would not be the
287
287
default.
288
288
@@ -331,16 +331,16 @@ accepted. For example, ``NoRowIndex`` would not necessarily need to subclass
331
331
** Q: Would `` .loc `` stop working?**
332
332
333
333
** 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
335
335
continue working.
336
336
337
337
** Q: What's unintuitive about `` Series `` aligning indices when summing?**
338
338
339
339
** A:** Not sure, but I once asked a group of experienced developers what the
340
340
output of
341
341
``` 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 ])
344
344
print (ser1 + ser2)
345
345
```
346
346
would be, and _ nobody_ got it right.
0 commit comments