I have writter the following function:
def extract_id(df, col):
column = df[col]
placement_extract = column.str.extract('(\d{14})', expand=True)
for placement in column:
if placement in placement_extract == True:
return placement_extract
else:
return 'False'
atlas_df['test'] = extract_id(atlas_df, 'PlacementName')
When I apply though, I get an error
ValueError: cannot convert float NaN to integer
What I'd like to do is to apply the function, if the extract is true for that placement (row) then give me the 14 numbers. If not, return the word False.
Can somebody help?
Best,
M
Aucun commentaire:
Enregistrer un commentaire