The example pandas syntax of using apply with dataframes is overly complex for the specific example of calculating a new efficiency feature. Instead of: efficiency = df.apply(lambda x: x['displacement']/x['horsepower'], axis=1) df['efficiency'] = efficiency This can be more directly and intuitively coded with something like: df["efficiency"] = df["displacement"]/df["horsepower"] But the purpose of the lesson is to demonstrate how to apply functions over a dataframe so this simple example is really helpful. Your channel is such a valuable resource thanks Jeff!
The example pandas syntax of using apply with dataframes is overly complex for the specific example of calculating a new efficiency feature. Instead of:
efficiency = df.apply(lambda x: x['displacement']/x['horsepower'], axis=1)
df['efficiency'] = efficiency
This can be more directly and intuitively coded with something like:
df["efficiency"] = df["displacement"]/df["horsepower"]
But the purpose of the lesson is to demonstrate how to apply functions over a dataframe so this simple example is really helpful. Your channel is such a valuable resource thanks Jeff!
Thanks, Jeff.
welcome sir
I'm getting an error when trying to access the tax-zip code data file:
URLError:
Might this have something to do with my location (Europe)?
Although lot these pandas functions are useful, their syntax is not intuitive to use unlike R.
Not sure, it's only me or others feel the same