FAQ: The Data Analyst Process - Cleaning Data

This community-built FAQ covers the “Cleaning Data” exercise from the lesson “The Data Analyst Process”.

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

Data Analyst

FAQs on the exercise Cleaning Data

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!
You can also find further discussion and get answers to your questions over in Language Help.

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

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

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!

Hi everyone,

I have a question about the syntax of this command/code in the exercise:
<
new_df = pd.merge(user_data, pop_data)
new_df.loc[new_df.population_proper < 100000, “location”] = “rural”
new_df.loc[new_df.population_proper >= 100000, “location”] = “urban”

I understand the syntax overall, excluding the
<new_df.loc[new_df.population_proper >= 100000, “location”] = “urban”>

May I ask, what is the meaning of it

Hi all, The logic seems straightforward, and I have added my commands. But where can one “inspect” the new table? I am sure it is simple, what am I missing?

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.loc.html

I found this explanation for it!

Essentially loc is a property of Pandas dataframe; we are selecting the row/columns that we need to filter by or examine. For instance in the example exercise, from the dataframe “new_df” we are selecting the column new_df.population_proper and using the selected column’s values to create a boolean expression that will help us determine if the town/city is urban/rural.

If the population_proper column/variable is < or >10,000; the newly created column “location” will be assigned the value “urban” or “rural” for that row.

Sorry if that wasn’t the best explanation. I am new to CodeCademy!

2 Likes

any guidelines on using Pandas? Like installation? I have no idea what should I do now.