Apply same set of code to different subsets (original) (raw)

Python Help

custom-function

hazz292 (Hazz292)

January 11, 2023, 10:49am 1

Hello, I want to perform the same data preprocessing code with pandas to different subsets of dataframe. Is there any way to write the code more efficiently without repeating same code for 6 subsets?

Thank you!

MRAB (Matthew Barnett) January 11, 2023, 7:18pm 2

Put the code in a function and then call it for each subset?

1 Like