# pip install pandas
import pandas as pd
# Read the csv file
data = pd.read_csv('data.csv')
# Print it out if you want
print(data)
with open(r'c:dlFrameRecentSessions.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 0:
print(f'Column names are {", ".join(row)}')
line_count += 1
else:
print(f' {row[0]} works in the {row[1]} department, and was born in {row[2]}.')
line_count += 1
print(f'Processed {line_count} lines.')
# importing Pandas library
import pandas as pd
pd.read_csv(filepath_or_buffer = "pokemon.csv")
# makes the passed rows header
pd.read_csv("pokemon.csv", header =[1, 2])
# make the passed column as index instead of 0, 1, 2, 3....
pd.read_csv("pokemon.csv", index_col ='Type')
# uses passed cols only for data frame
pd.read_csv("pokemon.csv", usecols =["Type"])
# returns pandas series if there is only one column
pd.read_csv("pokemon.csv", usecols =["Type"],
squeeze = True)
# skips the passed rows in new series
pd.read_csv("pokemon.csv",
skiprows = [1, 2, 3, 4])
dataFrame = pd.read_csv("C:Usersamit_DesktopCarRecords.csv")
this is for csv file python