Saturday, 30 December 2017

Python Pandas

Pandas is an amazing library, so amazing that there are numerous books out there on it, some of which I am happy to say I own. There are so many things that you can do with python that I am not really sure where to start with a series of posts on it.

I guess the key place to start is with a pandas dataframe. I guess the easiest way to describe a basic dataframe is as an excel like grid. There are many ways to set up a dataframe, in my example I have chosen to read a csv file. This is a basic csv file that looks like this...

CSV screenshot

dataframe head screenshot
So in a few lines of code we have imported a file and shown that it looks as we would expect, note you can use the head and tail functions to show the top n and bottom n rows. I have also included in the code a few examples of other basic things I have done in a dataframe
  • Rename columns
  • Drop Columns
  • Get Unique values
There are so many other things I could show but the post would become huge so I will tackle them on a more logical basis.
The code: 

No comments:

Post a Comment