Legacy – Creating a DataFrame
- 01:50
Learn about a DataFrame and How to Create a DataFrame in Python.
Downloads
No associated resources to download.
Glossary
Creating a DataFrame Dataset Pandas LibraryTranscript
A DataFrame is a major object in Python. A lot of data manipulation and data visualisation and data modelling happens using the DataFrame. So being able to create a DataFrame is important knowledge to have. Apart from importing data from a different Excel file and transforming into a DataFrame. Creating our DataFrames from scratch is really important to know, we can use dictionaries to create a DataFrames. And this is the best option because when creating a dictionary, we have the option of having an item and a key. There are many other options available. This is not just restricted to just having a dictionary to create a data frame. So before creating a data frame, we have to import the pandas module. We can import it as pd or some of the shorter form. But import pandas as pd is a general rule that is borrowed across. So once the pandas module is imported as pd, we can create a data frame using the syntax shown on the screen. So pd . data frame and we include the data, probably the data is created as a dictionary, so it would be pd . data frame, the dictionary and we have the indexing and the columns and there are many other options available. The index is the row label of the data frame and the columns are the column labels of the data frame. We can change the labels help or have something new. If we want to particular data from the data frame, we try to index it so we use the square brackets like when we are indexing or lists or we can use another one called . LOC and square brackets, which is just locating the specific data. Anything that goes within the square brackets need to either be single quotations or double quotations.