Creating Pandas DataFrames

 Creating a DataFrame by using a dictionary:

familyDict = {
    "Names": ["Rehman", "Wadud", "Wahab", "Aasia", "Memoona"],
    "Age" : [35, 26, 30, 24, 39],
    "Qualification": ["Pharm-D", "B-Tech", "Civil", "BA", "Islamyat"],
    "Relation" : ["Son", "Son", "Son", "Daughter", "Daughter"],
    "Status" : ["Married","Married","Married","Married","Married"]    
}
import pandas as pd
family_table = pd.DataFrame(familyDict)
family_table.index = [1,2,3,4,5] # changes the index pattern of the table
print(family_table)


Creating a DataFrame by importing a CSV file using Pandas

import pandas as pd

notes = pd.read_csv("CSV-notes.csv")
print(notes)



Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes