Skip to content

cmg-git/pandas_triks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Make Pandas much faster by vectorization

Based on Make Your Pandas Code Lightning Fast.

Problem:

Apply a logical condition across every row of a DataFrame. Assign the result to a new column.

Solutions:

Level 1 Looping:

  • Define a function with the logic for rewarding for each row (i.e., person).
  • Loop over each row of the DataFrame to apply the condition to obtain the value and assign it to a cell.

Level 2: Vectorization:

  • Apply the logical conditions to the whole DataFrame.
  • Assign the default values to the column.
  • Assign the Series of calculated values with condition.

The implementation is in vectorize_conditions.ipynb and vectorize_conditions.py. The notebook can be run on MyBinder.org.

Binder

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published