Learn how to use categorical data in Pandas. You mostly use categorical data to save memory. You can see how to measure memory consumption of Pandas DataFrame.
- [Instructor] We have a vendor id column…which is an integer.…Let's see how many values other.…Df VendorID.unique.…We have only two values.…We'd like to refer to them by name.…To find the names, you need to read the documentation…about the data.…If you look at the PDF,…we can see that one is Creative Mobile Technologies…and two is VeriFone Inc.…Let's add a column called vendor with the names.…Df.vendor will be df.vendorid…and we're going to do an apply…and we'll create a mapping between 1 to creative…and 2 to VeriFone and we pass the get method…of this dictionary to apply.…
Let's see what we get.…We get the column of strings.…Since we have only two vendors,…it seems wasteful to generate a string per row.…Let's see how much memory do we consume.…Df of vendor and let's look at the memory usage…and divide it by one here.…This kind of data, where there are a few possible values…that repeat, is called categorical data.…In Pandas, we have special type for categorical data.…
Let's do this again,…but this time we'll tell Pandas that we want the data…
- Working with Jupyter notebooks
- Using code cells
- Extensions to the Python language
- Markdown cells
- Editing notebooks
- NumPy basics
- Broadcasting, array operations, and ufuncs
- Folium and Geo
- Machine learning with scikit-learn
- Plotting with matplotlib and bokeh
- Branching into Numba, Cython, deep learning, and NLP
Skill Level Intermediate
1. Scientific Python Overview
2. The Jupyter Notebook
3. NumPy Basics
Manage environments5m 11s
6. Folium and Geo
7. NY Taxi Data
10. Other Packages
11. Development Process
Next steps1m 33s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.