I'm working with Python Pandas DataFrames and I'd like to split one cell into two by checking if a Substring appears in a list. I export the Data from an Excel-file.
The export:
excel = pd.read_excel(r'./data.xlsx')
This is how the data looks like if I print it: Data
This is my list that I'd like to use for splitting the cell:
doks = ["CCS CSC", "COBIT 5", "ISA 62443-2-1:2009", "ISA 62443-3-3:2013", "ISO/IEC 27001:2013",
"ISO/IEC 27019:2013", "BSI-Standard", "NIST SP 800-53 Rev. 4", "CIS CSC",
"NIST SP 800-53", "IEC 62351-8", "NERC CIP-002", "NERC CIP-003", "NERC CIP-004", "NERC CIP-005",
"NERC CIP-006", "NERC CIP-006, 007" "NERC CIP-007", "NERC CIP-008", "NERC CIP-009"]
This is my current status where I'm stuck:
def find_chapter(fullRef, dokuments):
for dokument in dokuments:
if dokument in fullRef:
chapter = fullRef.split(dokument)[-1]
return chapter
excel["Kapitel"] = excel.apply(lambda x: find_chapter(x["Referenzen"], doks), axis=1)