Pandas

Learn about Pandas, a Python data manipulation library. Pandas is used heavily used in data science operations.

Pandas is a Python library built over the NumPy package. Its key data structure is Data-Frame. Data-Frame allows a user to store and manipulate data in a tabular format.

Pandas data structures are fast and flexible. They are suitable for working with real-world data problems, and they provide a good set of functions for data scientists and data engineers. These function help the user get a jump-start on their data, allowing them to quickly build a predictive modeling pipeline.

Pandas
Pandas

Creating a Pandas DataFrame

There are multiple ways to create a Pandas DataFrame.

By Python dictionary:

Press + to interact
#Import libraries
import pandas
#Create a dictionary
data_dictionary = {
"City":['Delhi','Bombay','Pune','Hyderabad'],
"Population_Index": [19,21,7,9],
"Area_Type":['Metro','Metro','Non-Metro','Metro']
}
#Create DataFrame
city_data = pandas.DataFrame(data_dictionary)
print(city_data)

In the above example, indexes are coming from 0 to 3 (the length of the data list - 1). We can provide indexes also. See the example below: