I have the following dataframe:
import numpy as np
import pandas as pd
df1 = pd.DataFrame({'ID_df1': [1,2,3,4],
'Name_df1': ['John', 'Alex', 'Alan', 'Marie'],
'Cod_job_df1': ['10151444', '20555', None, '40']})
I need the items in the 'Cod_job_df1' column to have a total of eleven digits. So I made the following code:
df1['Cod_job_df1'] = df1['Cod_job_df1'].apply(lambda x: x.zfill(11))
This code was working perfectly. However, when I tested in a dataframe that has a column 'Cod_job_df1' equal to None, the error code and the message appears: AttributeError: 'NoneType' object has no attribute 'zfill'