The new case_when method in Pandas 2.2.0

preview_player
Показать описание
Pandas 2.2.0 includes a new method, case_when. What is it, and how can you use it? I give an overview, with a number of examples.

Here's a simple example of passing a callable, albeit not the most interesting one:

(lambda s_: s_.ge(500), 'high')])

The conditions here are lambdas (aka anonymous functions) that are invoked by case_when, rather than boolean series.
Рекомендации по теме
Комментарии
Автор

The info about default value was very helpful for me. Thank you👍

imothar
Автор

Reminds me of the case statement in SQL. I can see multiple situations that this will simplify my Pandas code, thanks for sharing!

christophertyler
Автор

great video! i still don't understand how you don't have at least 500k followers!

datossinmisterios
Автор

This is a good addition to Pandas functionality.

robertrussell
Автор

Thanks again for this video, it's always helpful. As a course suggestion: how to optimise the computation of data using the previous values in the series/df, especially when we need the result of the computation of the previous rows (i.e. multiprocessing not possible as you have to iterate the whole series in order).

ssss
Автор

Why do you import Series from pandas. Isn't that part of the whole package, already imported? Great content btw!

stefaandumez
Автор

This is nice but not so different than using np.where().
I belive np.where is much faster when dealing with big serieses.

ofirmazor
join shbcf.ru