Matplotlib and Seaborn Workout
- 01:46
Practice using Matplotlib and Seaborn in Python.
Downloads
No associated resources to download.
Glossary
Machine Learning Matplotlib Python SeabornTranscript
We're going to jump right in with a quick exercise in your Jupyter notebook. First import NumPy, Pandas, Pyplot from MaTplotlib and Seaborn. Then import stock data v2 into a new dataframe and display the first row. Then display the unique values in the sector feature.
So in this first cell I'm importing NumPy as np. I'm importing pandas as PD. From matplotlib I'm importing Pyplot and I'm giving it the alias PLT. And then I'm importing seaborn with the alias SNS.
I'm creating a new dataframe called stock data using the pandas read csv function. And I'm going in and I'm adding the file path to get stock data version 2 csv. When I execute that cell, I'll create the stock data dataframe. And then finally in this last cell, I am calling the stock data dataframe pointing to the sector feature, which I could also do with the square bracket method. And then I'm using the unique function to get the unique classes in that sector feature, you can see that a few of these unique values look like duplicates, and that's because they are typos. Specifically you can see this information technology class with an extra period at the end. That's an error. Industrials with the dollar sign instead of the S and energy with an S instead of the G. You can see that using this unique function is a good way to find typos in the various classes in a categorical feature like we have in sector right here.