import pandas import random import datetime PLACEHOLDER = "[NAME]" data = pandas.read_csv("birthdays.csv") new_dict = {row.month: row.name for (index, row) in data.iterrows()} print(new_dict["month"])
it is throwing an error when I try to print out new_dict["month"]
new_dict["month"]
ERROR: KeyError: 'month'
What the CSV file contains:
name,email,year,month,day
john,johndoe123@gmail.com,1995,1,6
if you want to use the dot notation just replace iterrows by itertuples:
dot
iterrows
itertuples
new_dict = {row.month: row.name for row in data.itertuples()}
1.4m articles
1.4m replys
5 comments
57.0k users