Skip to content
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

Typo in pandas tutorial 1? #287

Open
davidmcnamee opened this issue Jun 19, 2020 · 1 comment
Open

Typo in pandas tutorial 1? #287

davidmcnamee opened this issue Jun 19, 2020 · 1 comment

Comments

@davidmcnamee
Copy link

Hey, I was just going through the pandas tutorial and wasn't sure whether this is a typo or if I'm misunderstanding.

"Why the change? Remember that loc can index any stdlib type: strings, for example. If we have a DataFrame with index values `Apples, ..., Potatoes, ...`, and we want to select \"all the alphabetical fruit choices between Apples and Potatoes\", then it's a lot more convenient to index `df.loc['Apples':'Potatoes']` than it is to index something like `df.loc['Apples', 'Potatoet]` (`t` coming after `s` in the alphabet).\n",

it's a lot more convenient to index df.loc['Apples':'Potatoes'] than it is to index something like df.loc['Apples', 'Potatoet] (t coming after s in the alphabet)

Should the second code snippet be df.iloc['Apples':'Potatoes']? It was just explained that df.iloc[0:10] gives you indices 0,...,9 but df.loc[0:10] gives you indices 0,...,10; and then I wasn't sure how they got df.loc['Apples', 'Potatoet].

@GAGAN2608
Copy link
Contributor

GAGAN2608 commented Oct 28, 2020

@uWaterloo
I will say second code snippet can't be df.iloc['Apples':'Potatoes'].
Because iloc uses only integer type indexed value. If you want to use string value as index for accessing data from pandas dataframe then you have to use Pandas Dataframe loc method.

Now the second issue about df.loc['Apples', 'Potatoet']:
I will say typo mistake is about not mentioning apostrophe mark after Potatoet
Basically it will include Potatoet if there is any in the given dataframe.
Moreover they have mentioned to use df.loc['Apples', 'Potatoes'] over df.loc['Apples', 'Potatoet'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants