why cant i populate the ‘shoe_source’ column with this function?
orders[‘shoe_source’]= orders.shoe_material.apply(lambda x: ‘animal’ if orders.shoe_material == ‘leather’ else ‘vegan’)
you are using ‘lambda x’ but not using x in the lambda function. the lambda is being applied to each value in orders.shoe_material already (orders.shoe_material.apply) so you need to reference x in the lambda instead of the whole orders.shoe_material series.
try
How come that the usage of \ is very inconsistent in this lesson. It is really confusing to understand where one needs to place .
for instance: In the hint it directs us to place it after (OUTCOME IF TRUE)
I’m a bit confused about the differences in usage of ‘apply’ function in dataframes.
Say, how would each of orders.shoe_material.apply(…) and orders.apply(…) work out?
I was wondering why the solution doesn’t use the hint format in this module. The code is not readable and doesn’t fit the entire rhetoric of this module telling us to define our lambda equations first, then put them into the functional part of the code.
The interface seems to throw an error message when slashes aren’t used despite them not being necessary. I tried two different approaches and confirmed both work by printing the first 20 rows.
<orders['shoe_source'] = orders.shoe_material.apply(lambda x: 'animal' if x == 'leather' else 'Vegan')>
<orders['shoe_source'] = orders.shoe_material.apply(lambda x: 'Vegan' if x != 'leather' else 'animal')>
Also, for exercise #3, I literally copied the recommended code in the hint at one point and still got an error message for that line. The solution code makes a little more sense to me since it accomplishes the task in one step instead of having to define a function and then apply that function. I just wish there was more continuity in the approach throughout the modules and that the focus was always on the way to accomplish the task with the cleanest code possible.
A question:
To solve the exercise: Using the columns last_name and gender create a column called salutation which contains Dear Mr. <last_name> for men and Dear Ms. <last_name> for women.
I came out with the following solution:
orders[‘salutation’] = 'Dear ’ + orders[‘gender’].apply(lambda x: 'Mr. ’ if x == ‘Male’ else 'Ms. ') + orders[‘last_name’]
However it didn’t work out as planned. All the strings in the column are all started with ‘Dear Ms.’ instead of ‘Dear Ms.’ and ‘Dear Mr.’ separately.
you really need to be able to go back and look at your code after you ‘show solution’ so i can know wtf i did wrong. currently it just deletes what you wrote, no undo or back
your website is broken. it’s printing code that i deleted like 5 minutes ago and it won’t update to my current code. Refreshed the page, says connected but now:
Is anyone on this course within the Data Science Career Path?
I feel like I’m missing a lot. It’s a thought over the last few lessons. In this lesson one of the hints mentioned “.format”, which is something I haven’t been presented with yet. When I couldn’t figure it out and did the “solution” it didn’t even have it which was weird.
I looked at the course listing in the catalog and looks like the Data Science Career Path only puts you partway through the Python 3 course. Maybe it’s ‘enough’ depending, but I’m wondering if I went in and finished that course I would have the rest of the information I need. This ‘course’ if done standalone says you should have completed all of Python 2 (where the page says to take Python 3 if you can).
So, I guess I’m wondering if anyone else if having this issue.
I also feel the same way. I thought that the Data Science Career Path would take us all the way through these languages but it seems there are quite a few holes in the learning path. I’ll have to take the separate SQL and Python courses to supplement my knowledge, which is very frustrating. I paid for Pro and I’m not sure I’m getting my money’s worth.
I am encountering the same issues. One example from this lesson are “String Methods” which were necessary for completion but I don’t recall having covered them at all before this point. This is the second time on this path that I have encountered unfamiliar concepts which are necessary for understanding the lesson but haven’t been covered. It’s very frustrating and makes me feel like I’m not grasping the basics even though there are fundamentals being left out.