Got multiple rows in swifter.apply()
See original GitHub issueGreat tool! however I tried to do a simple
df.Column.swifter.apply(lambda x: x**2)
but x is a series of Column, not a single element so the process fails. Is this the intended behavior? Versions: Python 3.7.3, swifter 0.292, pandas 0.25.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Pandas apply with swifter on axis 1 doesn't return
apply returns more than one row to the function and breaks my code. I'm not sure what changed, but the code did run...
Read more >Swifter — automatically efficient pandas apply operations
An introduction to swiftapply, a generalized method for easily and efficiently applying any function to a pandas dataframe or series.
Read more >Speed up your Pandas Processing with Swifter
The problem is the bigger your data, the longer time to finish running each line of code. In this article, I want to...
Read more >Speed Up Pandas Dataframe Apply Function: 4 Techniques
Apply() : The Pandas apply() function is slow! ... User_loc.swifter.apply(lambda row: random_function(row) if (pd.notnull(row)) else row).
Read more >Return multiple columns using Pandas apply() method
apply() are Series objects whose index is either the DataFrame's index (axis=0) or the DataFrame's columns (axis=1). By default (result_type= ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the thoughtful response @jakubLangr. I have now fixed up PR #76, which tests that the intermediate applies have a redirected stdout. While we could add a kwarg to allow users to require non-redirected stdout during these applies, I don’t really see a use case in which someone would want that. So until someone asks for that capability I’d prefer to always redirect stdout in those situations.
Hi @jmcarpenter2 , thanks for your work!
I am experiencing a similar issue and even though I grokked that this is probably what is going on, this behavior still creates an uneven API and unexpected errors, so I would recommend giving the user an ability to control this e.g. with a kwarg.