Read CSV by Column in Pandas πŸ“Š

Learn how to selectively read CSV columns in Pandas to handle data efficiently and avoid loading unnecessary data.

Read CSV by Column in Pandas πŸ“Š
Learn Pandas
17.7K views β€’ Oct 30, 2018
Read CSV by Column in Pandas πŸ“Š

About this video

Learn how to read a CSV into Pandas by column. This allows you to read part of a CSV file instead of reading all the columns at once.

What is Pandas? A Python data analysis library

Even though the Jupyter notebook is wonderful. When you start to read in wide files, you start to notice some issues. when the file you are reading has a lot of column, things don't look that nice anymore. Now the exception are those of you who have really wide screens. But even so, if all you need to see is a few columns, then there is not point in reading in 1 columns.. right?

This video starts out by loading up into Pandas a tiny CSV file. If you have not seen my other video on reading a text file, go get it here:
https://youtu.be/zbLyOVKqwWw

Now I know that the file we placed in a dataframe has only three columns, but remember this is a tutorial and I want to make sure things are easily understood. The usecols parameter is introduced and this is the parameter that you will use to read in partially the CSV file. We read in the gender column alone. Only one column was read by simply passing in the name of the column.

We then read in the other columns once at a time, but uncovered an issue. Reading from a flat file might introduce spaces and other odd characters where you least expect them. Not a huge issue and we were able to overcome that data issue pretty easily.

Since the usecols parameter takes in a Python list, we could pass in multiple columns and you will get just those columns back. We also went over reading in files by position instead of by column name. This is wonderful as we don't always know the column names.

πŸ”₯ Free Pandas Course: https://hedaro.gumroad.com/l/tqqfq

Tags and Topics

Browse our collection to discover more content in these categories.

Video Information

Views

17.7K

Likes

118

Duration

6:04

Published

Oct 30, 2018

User Reviews

4.2
(3)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.