Skip to content
Advertisement

pandas explode column only non zero values

How to filter tolist or values below to get only non-zeros

JavaScript

Data

JavaScript

On Explode on Column D rows now becomes 9. But i want 4 rows in the output

Expected result

JavaScript

I got list(filter(None, [1,0,2,3,0])) to return only non-zeros. But not sure how to apply it in the above code

Advertisement

Answer

Simpliest is query:

JavaScript

Output:

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