Beginners Introduction To Pandas

Beginners Introduction To Pandas

On the previous article we took the first steps to installing python and anaconda, we also went further and looked at the Numpy library. Today we going to have a look at another very important library that is useful in data science Pandas.

Pandas

Pandas is a library used for data manipulation and analysis that has two mainly used data structures:

Series: a one-dimensional structured table (that is, a single column table with index values).

DataFrame: a two-dimensional structured table (simply like tables in a spreadsheet).

We going to take a look on how to create a Series in Pandas, then work on DataFrame onwards. Let’s create a new notebook named Book2 and move on to importing our libraries, this time we’ll also add the Series module.

image.png

Let’s create our first Series :

image.png Let’s create conditional statements in our Series

image.png We can now try out Boolean Conditions

image.png Let’s convert our table, ‘animals’, into a dictionary:

image.png You can do more with pandas Series, check out their documentation here.

Let’s move on DataFrame!

We are going to import a dataset file in csv mode, you can download it at kaggle.

First and foremost we going to read the file using the pd.read_csv and print out the first five rows using df.head()

image.png To see the last five rows we do: df.tail(). Note that to see more rows, place your preferred number of rows within the parenthesis.

image.png Now that we have been able to read our file, we can find out the information contained in our dataset:

image.png

While checking the information lets also find out our dataset shape:

image.png It’s important to also know the description of your data, as it will help in your analysis:

image.png Another crucial thing when analysing data is to find out if your dataset has any null values as this affects your work and it is very important to find out:

image.png You can use the sum() function to simplify this method :

image.png

Here is the documentation for pandas DataFrame For further development, attempt opening non-CSV file formats on pandas, such as HTML, Excel, and JSON .

Let me know your thoughts, any questions and comments. Keep Smiling 🥰🥰

Did you find this article valuable?

Support V Thulisile Sibanda by becoming a sponsor. Any amount is appreciated!