top of page

Python pandas DataFrame - Tutorial 1

Python pandas help users manage data in an easy and efficient way. When I was a newbie for python, I managed data in lists. I had about 1500 x 650 data set, and I did calculations or anything I want with a lot of 'for loops' to go through the elements in the big list. Python pandas has powerful features that help our works easier!


This post will use a sample .csv file (the file can be downloaded from here). to show some examples, and jupyter notebook. The best way to learn pandas is practicing with your hands. All scripts below are images, so you need to type the codes on your computer rather than ctr+c and ctr+v, and just looking how it works.


Open csv file

'pd.read_csv' can read .csv, .xls, .txt, or .json. '2013_movies.csv' file was in the same folder, so the path was not included, but you can add a path for your file you want to read.

Convert string to time series

You can check information for columns with df.info().

'ReleaseDate' column is string, so when you want to use the date as actual date, strings will not work in a way you want. We want to convert the strings to date. One simple line will do it.


df['date']= pd.to_datetime(df['ReleaseDate'])

pd.to_datetime is a built-in function in pandas and it will convert 'ReleaseDate' column to time series data. Now let's check how it was converted.











'date' column that we just added is time series data.



Select specific column to display


When you select column from DataFrame, you can use bracket and quotation mark, or period does the same thing for columns. Here are some examples below. .head() shows only first five rows. You can decide the number of rows to display by assigning a integer in the parenthesis.







Plot columns

Since we converted 'ReleaseDate' to time series, let's plot 'DomesticTotalGross' against time. Here I will use 'matplotlib'.

More useful tools in pandas will be posted on the next tutorial.

Featued Posts 
Recent Posts 
Find Me On
  • LinkedIn Social Icon
Serach By Tags

© 2017 by Jay Kim.

  • LinkedIn Social Icon
bottom of page