Skip to content
Advertisement

How to split the columns values separated by commas, into multiple rows and also splitting the total revenue by quantity

if u see the screenshot in that f4,f5, and f9 columns values are separated by commas, i want to split that values into different rows, and f9 is a total number of products, so I need to split the revenue as well based on quantity, for example total number of products according to f9 is 5, so total revenue is 211.32, so each row it should be (211.32/5)*2(quantity value)

enter image description here

I tried this:

JavaScript

but didn’t work..

Advertisement

Answer

You have to develop a specific function to do this (with or without pandas).

Let’s consider you have a classic Python list:

JavaScript

you can create a small function which reads the fields and “split” the columns. Here is an example:

JavaScript

This generator can be used like this:

JavaScript

You get:

JavaScript
Advertisement