Skip to content

DOC: GH2072 add example and warning on fallback indexing for float indexes. #3128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2013

Conversation

adamgreenhall
Copy link
Contributor

@jreback
Copy link
Contributor

jreback commented Mar 21, 2013

can you make the doc lines wrap, no more than 80 char width. (I get flagged for this all the time!)

Looks good otherwise

@y-p ?

@jreback
Copy link
Contributor

jreback commented Mar 21, 2013

also, maybe add an example of using the 'float' selection, e.g

say A is your previous indexer column
something like this?

df[(df.A>=1.0) & (df.A<2.0)]

@ghost
Copy link

ghost commented Mar 21, 2013

instead use use - needs fixing.

very bad idea is not the best pharsing IMO. explain the problem. explain the caveats,
recommend a better way.

Also, I can't parse:
If you do have a float index, an integer label will fallback to
it seems disjointed.

I haven't followed this issue, so i'm looking at the doc with fresh eyes... ;)

@ghost
Copy link

ghost commented Mar 21, 2013

Oh, re 80 char limit on documentation - stop the PEP8 insanity! it's not even code!

@adamgreenhall
Copy link
Contributor Author

Good point @y-p. How about this?

@jreback
Copy link
Contributor

jreback commented Mar 21, 2013

looks good to me (and now you are taking style points from @y-p )....!

@ghost
Copy link

ghost commented Mar 21, 2013

Hey- if you don't want pedantry, don't ask for my opinion on docs.

@jreback
Copy link
Contributor

jreback commented Mar 21, 2013

and if you wouldn't mind, pls rebase into 1 commit

git rebase -i <first commit>

change the pick to fixup (or squash if you want) for all but the first

then

git push <your fork> <this branch name> -f

@adamgreenhall
Copy link
Contributor Author

@jreback - done. I wondered how that worked in git - thanks.

@jreback
Copy link
Contributor

jreback commented Mar 21, 2013

this looks great

I'll leave open for a couple of days in case you want to change anything
(I find that I read doc updates and then I edit them the next day)

@ghost
Copy link

ghost commented Mar 21, 2013

yep, this is good.

jreback added a commit that referenced this pull request Mar 22, 2013
thanks for the pr! 
DOC: GH2072 add example and warning on fallback indexing for float indexes.
@jreback jreback merged commit f15b176 into pandas-dev:master Mar 22, 2013
@adamgreenhall adamgreenhall deleted the doc_fallback_index branch March 23, 2013 00:48
@jreback
Copy link
Contributor

jreback commented Mar 24, 2013

@adamgreenhall
in http://pandas.pydata.org/pandas-docs/dev/indexing.html#fallback-indexing

I realized that the last part of your example is correct, but not illustrating what I think you want.

df_new.index is the index in this case, but you want to illustrate df_new['index']

In [14]: df_new
Out[14]: 
   index         A         B         C         D
0      1 -1.164567  0.054407  0.619462  1.936210
1      2  0.047871 -1.776328 -0.590250 -0.399167
2      3  0.214890 -0.593469 -1.115490  0.259086
3      4  0.089140 -0.998506  0.514325 -0.719256
In [15]: df_new[df_new.index==1.0]
Out[15]: 
   index         A         B        C         D
1      2  0.047871 -1.776328 -0.59025 -0.399167

In [16]: df_new[df_new['index']==1.0]
Out[16]: 
   index         A         B         C        D
0      1 -1.164567  0.054407  0.619462  1.93621

Same here

In [17]: df_new[(df_new['index']>=1.0) & (df_new['index']<2)]
Out[17]: 
   index         A         B         C        D
0      1 -1.164567  0.054407  0.619462  1.93621

Doing something like this might make the example more clear (then you can use df_new.my_float_index
that's my 2c

df_new = df.reset_index().rename(columns = dict(index = 'my_float_index'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants