Timeline for answer to How are iloc and loc different? by Alex Riley
Current License: CC BY-SA 4.0
Post Revisions
36 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 9, 2024 at 12:42 | comment | added | nutty about natty | Should be read in conjunction with this great answer to stackoverflow.com/questions/509211/how-slicing-in-python-works. | |
| Jun 6, 2023 at 14:05 | comment | added | tb. | This is great, and confirms that I will never use loc / iloc as even when its well explained, its overly convoluted. I cant imagine too many scenarios where you'd use this in a dataframe too big to view on your screen, definitely can't imagine enough of them to make it worth doing this vs subsetting based on column values. Much appreciated. | |
| Jul 12, 2021 at 17:23 | history | edited | Parham | CC BY-SA 4.0 |
incorrect number of rows returned specified
|
| Jan 2, 2021 at 17:33 | history | edited | Alex Riley | CC BY-SA 4.0 |
Remove info about ix as it is very out-of-date now. Generally improve answer to emphasise differneces in loc/iloc.
|
| Jan 2, 2021 at 17:24 | history | edited | Alex Riley | CC BY-SA 4.0 |
Remove info about ix as it is very out-of-date now. Generally improve answer to emphasise differneces in loc/iloc.
|
| Jul 1, 2019 at 7:00 | comment | added | Ben | How would the syntax look like when the labels are in the columns? Just swapping row and column information inside the brackets do not appear to solve that? | |
| May 31, 2019 at 12:47 | history | bounty awarded | coldspeed95 | ||
| Jun 20, 2018 at 15:48 | comment | added | Thomas | I am really sad they deprecated ix. Usually, I know how my dataframe looks, and writing my_dataframe_name.get_loc() and then remembering that I have to offset by 1 feels incredibly unwieldy compared to R's syntax... | |
| Dec 26, 2017 at 4:01 | comment | added | Antony Hatchkins |
Thanks! Nice and clear explanation! One suggestion: maybe it makes sense to move everything related to ix to a separate section of the answer if it is deprecated now?
|
|
| Dec 16, 2017 at 19:06 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 184 characters in body
|
| May 6, 2017 at 9:25 | history | edited | Alex Riley | CC BY-SA 3.0 |
update following .ix deprecation
|
| Dec 20, 2016 at 18:00 | comment | added | JohnE | In case you want to update this answer at some point, there are suggestions here for how to use loc/iloc instead of ix github.com/pandas-dev/pandas/issues/14218 | |
| Nov 3, 2016 at 7:57 | review | Suggested edits | |||
| Nov 3, 2016 at 8:50 | |||||
| Apr 29, 2016 at 9:18 | comment | added | Alex Riley |
@cjm2671: both loc or ix should work in that case. For example, df.loc['2016-04-29', 'Cash'] will return all row indexes with that particular date from the 'Cash' column. (You can be as specific as you like when retrieving indexes with strings, e.g. '2016-01' will select all datetimes falling in January 2016, `'2016-01-02 11' will select datetimes on January 2 2016 with time 11:??:??.)
|
|
| Apr 29, 2016 at 8:51 | comment | added | cjm2671 |
What do you use if you want to lookup a DateIndex with a Date, or something like df.ix[date, 'Cash']?
|
|
| Aug 19, 2015 at 14:01 | vote | accept | AZhao | ||
| Aug 18, 2015 at 9:24 | audit | First posts | |||
| Aug 18, 2015 at 9:36 | |||||
| Aug 2, 2015 at 2:07 | audit | Low quality answers | |||
| Aug 2, 2015 at 2:08 | |||||
| Jul 24, 2015 at 15:06 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 113 characters in body
|
| Jul 24, 2015 at 15:00 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 113 characters in body
|
| Jul 24, 2015 at 14:26 | history | edited | Alex Riley | CC BY-SA 3.0 |
oops... wrong way round
|
| Jul 24, 2015 at 14:18 | audit | Low quality answers | |||
| Jul 24, 2015 at 14:33 | |||||
| Jul 23, 2015 at 22:45 | history | edited | Alex Riley | CC BY-SA 3.0 |
deleted 5 characters in body
|
| Jul 23, 2015 at 20:50 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 1 character in body
|
| Jul 23, 2015 at 20:24 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 976 characters in body
|
| Jul 23, 2015 at 20:16 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 976 characters in body
|
| Jul 23, 2015 at 19:06 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 56 characters in body
|
| Jul 23, 2015 at 18:56 | comment | added | Alex Riley |
@measureallthethings: loc, iloc and ix might still trigger the warning if they are chained together. Using the example DataFrame in the linked docs dfmi.loc[:, 'one'].loc[:, 'second'] triggers the warning just like dfmi['one']['second'] because a copy of data (rather than a view) might be returned by the first indexing operation.
|
|
| Jul 23, 2015 at 18:44 | vote | accept | AZhao | ||
| Jul 23, 2015 at 18:44 | |||||
| Jul 23, 2015 at 18:36 | comment | added | measureallthethings | Great explanation! One related question I've always had is what relation, if any, loc, iloc and ix have with SettingWithCopy warnings? There is some documentation but to be honest I'm still a little confused pandas.pydata.org/pandas-docs/stable/… | |
| Jul 23, 2015 at 18:18 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 63 characters in body
|
| Jul 23, 2015 at 17:55 | vote | accept | AZhao | ||
| Jul 23, 2015 at 18:44 | |||||
| Jul 23, 2015 at 17:52 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 341 characters in body
|
| Jul 23, 2015 at 17:40 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 26 characters in body
|
| Jul 23, 2015 at 17:30 | history | edited | Alex Riley | CC BY-SA 3.0 |
added 26 characters in body
|
| Jul 23, 2015 at 16:59 | history | answered | Alex Riley | CC BY-SA 3.0 |