-2
I have a spreadsheet with thousands of products according to the example below, where the code is only in the type of service (left column), and I want it to be in all products of the same type (right column). In practice, I want code 1 to be dragged to code 2, and this to code 3, and so on. There is something ready in pandas for this?
This solution will not be useful, because there are thousands of elements that are arranged in this way (one on top of the other), and I cannot look at one to know how many codes have and apply this solution. My spreadsheet was exemplifying. I want that whenever the code column shows some value, this value is repeated until you find the next one, exactly like this one in the right column. Another thing: I exemplified with code 1, 2 and 3. But it may be that the column contains code 11, then code 9, that is, it is not sequential.
– Roger Regor
The second part of my solution is general
– Leonardo Bohac
Blz. I tried to run and give this message: /usr/lib/python3/dist-Packages/ipykernel_launcher.py:1: Futurewarning: elementwise comparison failed; returning scalar Instead, but in the Future will perform elementwise comparison """Entry point for Launching an Ipython kernel.
– Roger Regor
How does Dataframe look after you run it? And how is Dataframe before you run it? To help you I need to see the real Dataframe (or at least part of it); not a photo of a spreadsheet in Excel.
– Leonardo Bohac
I changed the original question and inserted the dataframe into it. It is thus after executing the command that Voce suggested.
– Roger Regor
Thank you! And before you run?
– Leonardo Bohac
Friend, your code does nothing but return that error message I gave you. Before and after executing your code, the dataframe looks exactly like this, without any changes
– Roger Regor
It’s more important for me to see how Dataframe is before you run. In case, if you’re saying it looks the way you showed it. Then you need to make some changes first. I will edit my reply.
– Leonardo Bohac
The df before I execute the command (so I care for the pandas), is the way I posted, and then also. IE, there is no change.
– Roger Regor
See if you go now
– Leonardo Bohac
Wonderful, it worked. And' that’s just what I need. Thank you very much.
– Roger Regor