Pandas Iterate Over Rows | Slow to Fast - 5 Methods

Опубликовано: 16 Октябрь 2024
на канале: Greg Kamradt (Data Indy)
8,175
121

https://dataindependent.com/pandas/pa...

Folks come to me and often say, "I have a Pandas DataFrame and I want to iterate over rows." My first response is, are you sure? Ok, fine, let's continue.

Depending on your situation, you have a menu of methods to choose from. Each with their own performance and usability tradeoffs. Here are the methods in recommended order:

DataFrame.apply()
DataFrame.iterrows()
DataFrame.itertuples()
Concert to DataFrame to Dictionary
DataFrame.iloc