I’m working on the visualize data with python course. I’m working on the data visualization portfolio project.
I’ve downloaded a csv file for the data. Whenever I try to use seaborn to make visualization, such as barplots, scatterplots, I keep getting messages that jupyter notebook is unable to interpret the data because the information isn’t numeric. How do I get the information to be numeric?
https://www.codecademy.com/paths/visualize-data-with-python/tracks/visualize-data-with-python-portfolio-project/modules/visualize-data-with-python-portfolio-project/kanban_projects/data-visualization-portfolio-project
What is the dataset for this project? Can you please paste your formatted code and where you get the error?
Did you check the data types? df.info()
?
https://seaborn.pydata.org/tutorial/data_structure.html
1 Like
Thanks for the link.
The data set focuses on car prices and their mileage. I’m trying to find a link between car prices and their mileages.
The code is:
“sns.barplot(data=cars, y=‘Mileage’, x=‘Price’)”
The error message is:
“Neither the x
nor y
variable appears to be numeric.”
This is the message when I use cars.info():
<class ‘pandas.core.frame.DataFrame’>
RangeIndex: 4999 entries, 0 to 4998
Data columns (total 2 columns):
Column Non-Null Count Dtype
0 Price 4999 non-null object
1 Mileage 1830 non-null object
dtypes: object(2)
memory usage: 78.2+ KB
Seems like you have to change the data type to something more specifically numeric (int64, float64, etc). It’s currently the catch-all dtype, “object”.
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.astype.html
This is the information I get when I use
cars.info()
Data columns (total 14 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Unnamed: 0 46022 non-null int64
1 Company Name 46022 non-null object
2 Model Name 46022 non-null object
3 Price 46022 non-null int64
4 Model Year 46022 non-null int64
5 Location 46022 non-null object
6 Mileage 46022 non-null int64
7 Engine Type 46022 non-null object
8 Engine Capacity 46022 non-null int64
9 Color 46022 non-null object
10 Assembly 46022 non-null object
11 Body Type 46022 non-null object
12 Transmission Type 46022 non-null object
13 Registration Status 46022 non-null object
dtypes: int64(5), object(9)
memory usage: 4.9+ MB
When I use sns.barplot(data=cars, x='Price', y='Mileage')
plt.show()
I still get a message saying Neither the x
nor y
variable appears to be numeric.
I installed the latest updates for seaborn.
I’ve tried running the cells again but I keep getting a message saying “The kernel appears to have died. It will restart automatically.”