question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Got multiple rows in swifter.apply()

See original GitHub issue

Great 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcarpenter2commented, Sep 17, 2019

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.

0reactions
jakubLangrcommented, Sep 13, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found