python - pandas apply function that returns multiple values to rows in pandas dataframe - Stack Overflow
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Find centralized, trusted content and collaborate around the technologies you use most. Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Get early access and see previews of new features. I have a dataframe with a timeindex and 3 columns containing the coordinates of a 3D vector: I would like to apply a transformation to each row that also returns a vector but if I do: I end up with a Pandas series whose elements are tuples. This is beacause apply will take the result of myfunc without unpacking it. How can I change myfunc so that I obtain a new df with 3 columns? Edit: All solutions below work. The Series solution does allow for column names, the List solution seem to execute faster. Return Series and it will put them in a DataFrame. This has the bonus that you can give labels to each of the resulting columns. If you
python - pandas apply function that returns multiple values to rows in pandas dataframe - Stack Overflow New: Stack Overflow For Agents. The next generation of knowledge exchange. Learn more Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives Stack Internal Knowledge at work Bring the best of human thought and AI automation together at your work. Explore Stack Internal pandas apply function that returns multiple values to rows in pandas dataframe Ask Question Asked 12 years, 1 month ago Modified 4 y
Explore this link on the map →saved by
related reading
- Pass data between tasks | Astronomer Documentationastronomer.io
- Intro to data structures — pandas 3.0.3 documentationpandas.pydata.org
- pandas.DataFrame — pandas 3.0.5 documentationpandas.pydata.org
- 12 Tidy data | Python for Data Sciencebyuidatascience.github.io
- Getting started — pandas 3.0.3 documentationpandas.pydata.org
- Redirecting...inferentialthinking.com
- pandas (software) - Wikipediaen.wikipedia.org
- CSC 151 - Transforming listseikmeier.sites.grinnell.edu
- A practical introduction to functional programmingmaryrosecook.com
- 9.9. 时间/日期函数和操作符postgres.cn
- CSC 151 - The "big three" list operationseikmeier.sites.grinnell.edu
- An introduction to functional programmingcodewords.recurse.com