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
Post a Comment
Write something to CodeWithAbdur!