How to Create a Pandas DataFrame




[ad_1]

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.
https://www.youtube.com/watch?v=Eiz4bwggQDY

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.

https://youtu.be/yVbz73ZJylI

Where can I find the Pandas tutorials for new users?
http://www.hedaro.com/pandas-tutorial

Source


[ad_2]

Comment List

  • Learn Pandas
    January 24, 2021

    Sorry but not only do you do too quickly but you’re not explaining what you’re doing

  • Learn Pandas
    January 24, 2021

    how to change the y values sir ?

  • Learn Pandas
    January 24, 2021

    You’re a lifesaver

  • Learn Pandas
    January 24, 2021

    when I am trying to import data frame from pandas ,its showing an error stating that "cannot import name data frame" can anyone please help with this?

  • Learn Pandas
    January 24, 2021

    thank you very much.

  • Learn Pandas
    January 24, 2021

    Excel seems a lot easier to create data frames like the ones shown in this video.

  • Learn Pandas
    January 24, 2021

    Thank you!

  • Learn Pandas
    January 24, 2021

    @ 1:27 you get a pop-up for DataFrame( self, Data=None.. ) . How do I activate such feature? I am using Canopy

  • Learn Pandas
    January 24, 2021

    Thanks, I was totally lost and this was a lifesaver!

  • Learn Pandas
    January 24, 2021

    Thanks for sharing!

Write a comment