Doing some data cleaning in a CSV file. I want to convert some CSV data into HTML before uploading the data to a website.
I'm going through every cell in the column called 'Details' in a pandas dataframe.
If a cell starts with this character combination: \r\r\n \t, then I want to replace it with this: <ul><li>
df2 = df.copy() def startswith_replace (x, a, b): if x.startswith(a): x.replace(a, b) df2['Details'] = df2['Details']. apply(lambda x: startswith_replace(x, '\\r\\r\\n \\t', '\<ul\>\<li\>'))
When I run this, however, every cell in the 'Details' column is replaced with 'None' as its value.