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:
Pandas apply() function: https://pandas.pydata.org/docs/refere...
Python zip statement: https://www.w3schools.com/python/ref_...
Python key argument of one-star: https://stackoverflow.com/questions/3...
Enjoy!
Смотрите видео How to Use apply() function to Return Multiple Columns in Pandas DataFrame онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Data Science Garage 21 Октябрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,380 раз и оно понравилось 43 людям.