How to Use apply() function to Return Multiple Columns in Pandas DataFrame

preview_player
Показать описание
This tutorial demonstrated how to generate separate multiple Pandas DataFrame columns from single column. For example, if you have name and surname in one feature columns on Pandas DataFrame, you can automatically build two additional columns with name and surname separately.

For this we will use a simple Python function returning two values at the end. Then apply function is applied to our Dataframe incorporating zip statement with single-star key argument. This is only one line of Python line.

In our example, we just use a split function to simply split the given string argument in order to return two separate values out of our Python function.

This solution valid in any kind of #Pandas #Dataframe and can easily be applied in #datacleaning, feature engineering, or data exploration steps in your real data science or data analytics tasks.

Useful links:

Enjoy!
Рекомендации по теме
Комментарии
Автор

Thank you all for watching this video! It was quick one. If you want more fresh content, or you can suggest your topic, drop a comment right here!

Enjoy!

DataScienceGarage
Автор

Df[name_column].str.split("sep", expand=True)

ИванБ-нс
join shbcf.ru