How to Create a Pandas DataFrame
This video will show you the basics on how to create a Pandas dataframe. We will be converting a Python list/dictionary and turning it to a dataframe. This will be your introduction to dataframe basics!
We start by importing pandas in two different ways. We can just import pandas as usual or just import the specific functions or methods we plan to use in our analysis.
Our first example uses a Python list to create a dataframe. We then learn about the “columns” parameter that allows us to name the dataframe columns to a name of our choosing.
The second example use a Python dictionary to create a dataframe. The advantage here is that we get to name our dataframe columns from the beginning. This means we do not have to use the “columns” parameter we used in the first example. This is why it is so popular to go from dict to dataframe.
TIP: Get cooler looking dataframes
The jupyter notebook actually is powered by Boostrap (front-end framework). We can leverage this and make our dataframe tables look really cool. At least a lot better than what they normally look like. To learn more, click the link below.
The third and last example in this tutorial shows you how multiple columns are achieved via a Python dictionary or Python dict.
I hope you were able to follow along and learn how to create a Pandas dataframe. We used a dictionary and a list but there are even more possibilities.
If you are interested in learning more abut pandas. Please see the video below on plotting with Pandas.