[Python] Python data values shift on right for multiple coloumns and insert function

Discussão em 'Python' iniciado por Stack, Junho 26, 2025.

  1. Stack

    Stack Membro Participativo

    enter image description here

    Hi,

    I hope you're doing well. I’ve attached an image of the dataset I’m currently working on in my Python notebook. I’m in the process of cleaning the data, but I’m stuck on a few rows where some values are misaligned — they need to be shifted one cell to the right starting from different columns (e.g., from the 'Unit' or 'Shape' columns).

    In Excel, it’s straightforward to insert a cell and shift others, but I’m struggling to replicate this logic in Python using shift() or other functions. Additionally, I want to insert "mg" in the 'Unit' column where appropriate, and fill any resulting gaps with NaN. Could you please guide me on how to handle this in Python? Any help would be greatly appreciated.

    enter image description here

    This is the result I am expecting. Please help if you can.

    Continue reading...

Compartilhe esta Página