Pandas Read CSV by Column

Опубликовано: 29 Октябрь 2018
на канале: Learn Pandas
17,416
117

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:
   • Read a Text File using Pandas  

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


Смотрите видео Pandas Read CSV by Column онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Learn Pandas 29 Октябрь 2018, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 17,416 раз и оно понравилось 117 людям.