Skip to content
Advertisement

Python/Pandas:How to process a column of data like a dictionary

i have a csv lie this

JavaScript

i would like to sum the values from column “PDCP.RxBytesUl”,

PDCP.RxBytesUl = 5QI1+5QI2+5QI3+5QI4+5QI5+5QI6+5QI7+5QI8+5QI9

finally,the result is like this

JavaScript

At first I wanted to convert this column into a dict(), but I found the format was not right, i have no idea, please help me, thank you

Advertisement

Answer

You can use Regex based solution:

JavaScript

df:

JavaScript

Better code Suggested by Shubham :)

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement