/  Technology   /  Python program to Create and Print DataFrame
pandas-exercises (i2tutorials)

Python program to Create and Print DataFrame

What are DataFrames in Pandas?

Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). A Data frame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns.

How do we write a python program to Create and Print DataFrame

A) Below are the steps to be followed to write a Python program to Create and Print DataFrame

Step 1: We have to import Pandas and below is the code shown how it is imported.

import pandas as pd

Step 2: Import a CSV file from the local directory which contains the data

We have to use the method as pd.read_csv which means we are asking pandas to read the csv file which has been imported from local directory

In the next line, we read the data into “furniture” variable and execute

Furniture=pd.read_csv('C:/Users/LENOVO/Desktop/Furniture.csv')
Furniture

Output:

Serial          Product   Brand   Cost
0       1         sofa set     Jay  35000
1       2         side bed   Akhil  50000
2       3  nightstand lamp  Harsha  11000
3       4     coffee table   Bindu  19000
4       5         wall art   Divya   7777

Leave a comment