[Tutor] help with Pandas

Alan Gauld alan.gauld at yahoo.co.uk
Tue May 22 19:06:43 EDT 2018

On 22/05/18 18:13, Glenn Schultz wrote:

Cavbeat: I'm no dataframe expert so I'm going on
general principles here...

>  I am trying to apply the function to the data frame as follows:
> df['loanage'].apply(myfunction(x = 2, y = 10, z = 10, df['loanage]), axis = 0)

This looks wrong on several counts:

1) apply() usually takes a function object as the first argument not the
return value of a function call as here.

2) When calling a function using keyword arguments you re not allowe to
have non-keyword arguments following the keyword ones, so the df[...]
bit should be an error

3) The df['loanage] does not have a closing quote.

> I get value error: The truth in the series is ambigous.....

I'm not sure if any of the above would result in a ValueError
but its possible.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list