Objective: To format ['Birth Month'] with leading zeros
Currently, I have this code:
import pandas as pd
import numpy as np
df1=pd.DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6])])
df1['Birth Year']= np.random.randint(1905,1995, len(df1))
df1['Birth Month']= str(np.random.randint(1,12, len(df1))).zfill(2)
df1
Which produces a list of values in ['Birth Month'] which is not what I need:
A B Birth Year Birth Month
0 1 4 1912 [4 5 9]
1 2 5 1989 [4 5 9]
2 3 6 1921 [4 5 9]
Instead, I am looking for values and formatting like the following in ['Birth Month']:
A B Birth Year Birth Month
0 1 4 1912 04
1 2 5 1989 12
2 3 6 1921 09