I am trying to remove the brackets and apostrophes from a dataframe in pandas, so that I can further parse the timestamp, which is in this format: YYYY/MM/DD:HH:MM:SS.
The code I'm using looks like this:
finallog = newerlog.split()
ts = finallog[0::6]
ip = finallog[1::6]
proxy = finallog[3::6]
refurl = finallog[4::6]
requrl = finallog[5::6]
An example of an erroneous timestamp at the beginning of the dataframe is: ['2020/11/13:02:16:43 There are others in the dataframe that have an apostrophe, such as '2020/11/14:10:14:16 Of course, the final element has the closing inverse as the beginning example ']
Any advice on how to remove these? The timestamps need to be uniform length if I am to slice them further.
if you know all the erroneous characters already:
element = '["2020/11/13:02:16:43'
clean_element = element.replace('[', '').replace('"', '').replace("'", '').replace(']', '')
>> '2020/11/13:02:16:43'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.