I have a data frame with one column,
DF = pd.DataFrame({'files': ["S18-000344PAS", "S18-001850HE1", "S18-00344HE1"]})
I want to add another column with the substring of files, the final dataframe should look like
DF = pd.DataFrame({'files': ["S18-000344PAS", "S18-001850HE1", "S18-00344HE1"], 'stain': ["PAS", "HE1", "HE1"]})
I try
DF["Stain"] = DF.apply(lambda row: row.files[re.search(r'[a-zA-Z]{2,}', row.files).start():], axis=1)
But it returned
AttributeError: 'NoneType' object has no attribute 'start'
What should I do?