Timeline for answer to How can I iterate over rows in a Pandas DataFrame? by waitingkuo
Current License: CC BY-SA 4.0
Post Revisions
30 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 20 at 0:28 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Third iteration [<https://en.wikipedia.org/wiki/Cython> <https://en.wikipedia.org/wiki/Numba>]. More representative link text.
|
| Feb 20 at 0:22 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Second iteration. Fixed the weird syntax highlighting (as a result, the diff looks more extensive than it really is - use view "Side-by-side Markdown" to compare), etc.
|
| Feb 20 at 0:16 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
We don't have threads here (Stack Overflow is not a forum - see e.g. <https://meta.stackexchange.com/a/92115>. It is a think tank (see <https://meta.stackoverflow.com/a/325681>).
|
| Mar 19, 2025 at 19:03 | comment | added | Gabriel Staples | @Bill, I recommend you leave your comment. It + my response is useful and adds value. | |
| Mar 19, 2025 at 18:04 | comment | added | Bill | Sorry, @GabrielStaples is right. Ignore my comment (I can delete it if people prefer). | |
| Mar 18, 2025 at 23:15 | comment | added | Gabriel Staples |
@Bill, I don't think that is a feature of iterrows(), I think it happened when you created your dataframe. See here: pandas.pydata.org/docs/reference/api/…. And look into the following possible tools/fixes: df['column_name'] = df['column_name'].astype(int), df = df.convert_dtypes(), when reading a CSV: df = pd.read_csv('file.csv', dtype={'col1': int, 'col2': 'Int64'}).
|
|
| Dec 16, 2024 at 20:00 | comment | added | Bill |
Another thing with .iterrows() which I only noticed today is that in the case where the row contains only numeric values, any integer values are coerced to floats.
|
|
| Apr 15, 2024 at 21:26 | history | edited | wjandrea | CC BY-SA 4.0 |
Copy formatting from source, which includes links and bold.
|
| Nov 4, 2023 at 16:11 | comment | added | Gabriel Staples |
Although .iterrows() works, it is around 600x slower than the fastest technique. I speed test and demonstrate 13 ways to iterate over a Pandas DataFrame in my answer here. .iterrows() is the 2nd slowest. 11 of the 13 techniques are faster than .iterrows(), and most of them are still really easy once you see an example of how to do them.
|
|
| Apr 16, 2023 at 20:07 | history | edited | coldspeed95 | CC BY-SA 4.0 |
added 846 characters in body
|
| Jun 6, 2022 at 3:16 | history | edited | Mateen Ulhaq | CC BY-SA 4.0 |
Spacing.
|
| Jan 26, 2022 at 23:10 | history | edited | gcamargo | CC BY-SA 4.0 |
make sure indexes pair with number of rows
|
| S Dec 11, 2020 at 8:38 | history | suggested | Carlos Mougan | CC BY-SA 4.0 |
does not need numpy to run
|
| Dec 11, 2020 at 7:22 | review | Suggested edits | |||
| S Dec 11, 2020 at 8:38 | |||||
| Aug 23, 2020 at 10:17 | history | edited | coldspeed95 | CC BY-SA 4.0 |
added 4 characters in body
|
| Jul 2, 2020 at 15:10 | review | Suggested edits | |||
| Jul 3, 2020 at 13:20 | |||||
| Apr 2, 2020 at 2:36 | history | edited | tommy.carstensen | CC BY-SA 4.0 |
Updating url to avoid redirect.
|
| Jun 21, 2019 at 3:26 | history | edited | coldspeed95 | CC BY-SA 4.0 |
deleted 8 characters in body
|
| Jun 18, 2019 at 21:30 | history | edited | coldspeed95 | CC BY-SA 4.0 |
added 169 characters in body
|
| S Dec 19, 2018 at 19:00 | history | suggested | gcamargo | CC BY-SA 4.0 |
4 spaces indentation correction, and parenthesis on print to follow python 3
|
| Dec 19, 2018 at 18:10 | review | Suggested edits | |||
| S Dec 19, 2018 at 19:00 | |||||
| Nov 26, 2018 at 13:04 | review | Suggested edits | |||
| Nov 26, 2018 at 13:45 | |||||
| Oct 10, 2018 at 22:28 | review | Suggested edits | |||
| Oct 11, 2018 at 2:18 | |||||
| S Aug 13, 2018 at 13:57 | history | suggested | deepelement | CC BY-SA 4.0 |
Removed the line prefix so someone can easily copy/paste this snippet into code. I have done the copy/paste a few times and have am sick of manually removing the line prefixes/formatting.
|
| Aug 13, 2018 at 13:34 | review | Suggested edits | |||
| S Aug 13, 2018 at 13:57 | |||||
| Dec 7, 2017 at 22:48 | review | Suggested edits | |||
| Dec 8, 2017 at 0:19 | |||||
| S Jan 10, 2017 at 20:37 | history | suggested | Alexandre | CC BY-SA 3.0 |
broken documentation link
|
| Jan 10, 2017 at 18:53 | review | Suggested edits | |||
| S Jan 10, 2017 at 20:37 | |||||
| May 14, 2013 at 14:57 | vote | accept | Roman | ||
| May 10, 2013 at 7:07 | history | answered | waitingkuo | CC BY-SA 3.0 |