flâneur — a map of the web's best reading

python - pandas apply function that returns multiple values to rows in pandas dataframe - Stack Overflow

stackoverflow.com · 2,755 words · saved by 1 readers

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