I have a df with 18 columns and 15K rows.
df.info() gives for first column:
'''
0 Behandelcode 17451 non-null object
''' Converting all values in columns 'Behandelcode' to integers fails because some strings have a letter at the end, example: '''
(405, '33971'),
(406, '38154'),
(407, '033620A'),
(408, '33971'),
''' Every time a string has a letter at the end, length of string is 7.
I've been trying for too long now. So once again I need your help.
The question is: how can i iterate over column: df2['Behandelcode'], so that all values are kept in place, but (for example) the A in 0336620A on index row 407 gets deleted and only; 0336620 stays in place. And this for all the values ending with a letter.
I tried this, didn't work.... ( I did i, value because df['Behandelcode'] gives a series.
'''
for i, value in enumerate(df2['Behandelcode']):
y = len(value)
if y == 7:
value[:-1]
else:
value = value
''' Maybe there is a safer / more clean python method then working with len. For now, first things first and that is cleaning op this column so I can set it astype(int32). I would be very very thankfull if you can help me. greetings Jan