You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
- 216In contrast to what cs95 says, there are perfectly fine reasons to want to iterate over a dataframe, so new users should not feel discouraged. One example is if you want to execute some code using the values of each row as input. Also, if your dataframe is reasonably small (e.g. less than 1000 items), performance is not really an issue.oulenz– oulenz2019-10-16 08:53:24 +00:00Commented Oct 16, 2019 at 8:53
- 17If you are a beginner to this thread and are not familiar with the pandas library, it's worth taking a step back and evaluating whether iteration is indeed the solution to your problem. In some cases, it is. In most cases, it isn't. It is important to introduce beginners to the library by easing them into the concept of vectorization so they know the difference between writing "good code", versus "code that just works" - and also know when to use which.cs95– cs952023-04-18 07:15:22 +00:00Commented Apr 18, 2023 at 7:15
- Related: Are for-loops in pandas really bad? When should I care?Gabriel Staples– Gabriel Staples2023-10-05 03:25:05 +00:00Commented Oct 5, 2023 at 3:25
- See also: What is the most efficient way to loop through dataframes with pandas?.Gabriel Staples– Gabriel Staples2023-11-23 21:35:20 +00:00Commented Nov 23, 2023 at 21:35
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-py