FAQ: Exploring Data with Python - Data Types

This community-built FAQ covers the “Data Types” exercise from the lesson “Exploring Data with Python”.

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

[Beta] Getting Started with Python for Data Science

FAQs on the exercise Data Types

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!

Trying to enter “laptops.dtypes” to complete the assignment and it keeps failing. I even copied and pasted from the hints.


What am I doing wrong?

1 Like

Hey, i fixed the same problem just by copying all the problem from above and paste the laptops.dtype, it should look like this:
import pandas as pd
repair = pd.read_csv(‘repair.csv’)
laptops = pd.read_csv(‘laptops.csv’)
repair.dtypes
laptops.dtypes

Type your code below this:

YOUR SOLUTION HERE

Run it.
Save it.
Click Test Work.

1 Like

image
Why does that highlighted line come up at the end everytime when dataset_name.dtypes is commanded?

I think it’s b/c columns w/mixed data types are stored as object datatype.

See:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dtypes.html

And:
https://pandas.pydata.org/pandas-docs/stable/user_guide/basics.html#basics-dtypes

If you use df.info() you’ll see a more in-depth summary about the dataframe as well as the dtypes for each column:

laptops.info()

>><class 'pandas.core.frame.DataFrame'>
RangeIndex: 3511 entries, 0 to 3510
Data columns (total 5 columns):
 #   Column         Non-Null Count  Dtype  
---  ------         --------------  -----  
 0   problem        3511 non-null   object 
 1   brand          3511 non-null   object 
 2   repair_status  3511 non-null   object 
 3   event_year     3511 non-null   int64  
 4   age            815 non-null    float64
dtypes: float64(1), int64(1), object(3)
memory usage: 137.3+ KB

Hi lisalisaj, thanks a lot for your response.
While I do not fully understand all the details mentioned in the links, I am glad I learnt more about the ‘dataframe_name.info’ attribute.