I am trying to use an if statement to change values within a column if there length is greater than x
My csv data ..
ID Test_Case TC_NUM
14581,dialog_testcase_4000.0134_mvp_not_understood-inprogress.xml,4000.0134
14582,dialog_testcase_4000.0135_mvp_not_understood-inprogress.xml,4000.0135
14583,dialog_testcase_4000.0136_mvp_not_understood-inprogress.xml,4000.0136
14584,dialog_testcase_4000.0137_mvp_not_understood_6.2.0-inprogress.xml,4000.01376.2.0
14585,dialog_testcase_4000.0138_mvp_not_understood_6.2.0-inprogress.xml,4000.01386.2.0
What I want:
ID Test_Case TC_NUM
14581,dialog_testcase_4000.0134_mvp_not_understood-inprogress.xml,4000.0134
14582,dialog_testcase_4000.0135_mvp_not_understood-inprogress.xml,4000.0135
14583,dialog_testcase_4000.0136_mvp_not_understood-inprogress.xml,4000.0136
14584,dialog_testcase_4000.0137_mvp_not_understood_6.2.0-inprogress.xml,4000.0137
14585,dialog_testcase_4000.0138_mvp_not_understood_6.2.0-inprogress.xml,4000.0138
My current code is able to extract some of the right columns, but messes up if additional numbers are in there.
df1['TC_NUM'] = df1['TC_NUM'].str.replace(r'[^0-9.]+', '')
df1['TC_NUM'] = df1['TC_NUM'].str[:-1]
My thought/attempt as using an if statement to correct this.
if dfidtcnum(len['TC_NUM'] > 12):
print "True"
Aucun commentaire:
Enregistrer un commentaire