FAQ: Data Cleaning with Pandas - More String Parsing

This community-built FAQ covers the “More String Parsing” exercise from the lesson “Data Cleaning with Pandas”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Practical Data Cleaning

FAQs on the exercise More String Parsing

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Step one seems to be impossible since even copying and pasting the answer from the solution does not work. I get an AttributeError and cannot continue. This issue has been plaguing me repeatedly in the pandas section as you seem to not be able to use any methods on columns

I’ve seen this error a number of times as well. This occurs whether I’m on my iMac using Firefox or Safari, or on my raspberry pi using Chromium. Sometimes refreshing the page fixes the problem. Other times, going ‘Back’ works. Other times, nothing seems to work except using the solution option. I don’t like that approach either.

Here’s my full solution:

split_grade = students['grade'].str.split('(\d+)', expand=True)
print("split_grade\n", split_grade)
students.grade = split_grade[1].replace('[\s]', '', regex=True)
students.grade = pd.to_numeric(students.grade)
avg_grade = students.grade.mean()
print("average grade = ", avg_grade)

I am also having the same problem and its very frustrating. I have sent a message to the bot, lets see if someone gets back. In any case I am writing to ask about a question in this excercise. When we split the grade by the digits, why is it that we need to select the second item, i.e, index 1, instead of the first one. The number is at the beginning.

students.grade = students.grade.str.split(’(\d+)’, expand = True)[1]