Instagram
youtube
Facebook
Twitter

Read Data from a CSV File into a Pandas DataFrame

       A  Read Data from a CSV File into a Pandas DataFrame
       
       Short Description of the Program:

       This Python program uses Pandas to read a CSV file named 'data.csv' and store it as a DataFrame.
       
        
Explanation:

  • import pandas as pd
    Imports the Pandas library and gives it a short alias pd.

     
  • pd.read_csv('data.csv')
    Reads the content of 'data.csv' and stores it in the variable df.

     
  • df.head()
    Displays the first 5 rows of the DataFrame to verify the data.

     

Program:

import pandas as pd

df = pd.read_csv('data.csv') #please add a csv file

print(df.head())