I have been trying to use panda to parse date as string from my csv.
What I am trying to achieve here is to extract a row (from the csv) which contains two type of data, string and integer.
From here, I want to use docx-mailmerge to produce Microsoft Word reports.
For context, I was referring to the solutions here when figuring out: datetime dtypes in pandas read_csv
Thank you.
Here is error I am getting:
ValueError: invalid literal for int() with base 10: 'Num'
Here is my code:
import pandas as pd
headers = ['AA', 'Num']
dtypes = {'AA': 'str', 'Num': 'int'}
pdate = ['AA']
df = pd.read_csv('test1.csv',
header=None,
names = headers,
dtype = dtypes,
parse_dates = pdate,
date_parser=None)
top = df.head()
print(top)
Here is my csv file:
AA,Num
1/1/2020,5
2/1/2020,10
3/1/2020,15
4/1/2020,20
5/1/2020,25
6/1/2020,30
7/1/2020,35
8/1/2020,40
9/1/2020,45
10/1/2020,50
11/1/2020,55