Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

rows in the wrong place, I'm looking for a way to organize them in their proper column in an excel file with pandas [closed]

$
0
0

i want to move this values to another column

#i only want to keep the example: A123..., move the data to the right place, is a one row upI would like to know how I can clean this data, I have this error, I would like to organize these rows into columns since they are in a place they should not be, they should be one box above

for prev_idx, (_, row) in enumerate(df.iterrows()):    if '...' in row['Plnt']:        idx = prev_idx - 1  # Get the index of the previous row        if idx >= 0:  # Check if prev_idx is valid            df.at[df.index[idx, 'SC']] = row['Plnt']            df.at[df.index[idx, 'ASN Ship']] = row['Supplier']elif ':' in row['Plnt'] or '...' in row['Supplier']:        idx = prev_idx - 1  # Get the index of the previous row        if idx >= 0:  # Check if prev_idx is valid            df.at[df.index[idx, 'Quantity']] = row['Pur. Doc.']            df.at[df.index[idx, 'Created By']] = row['Item']df.columns = df.columns.str.strip()df.columns.values

but i got this error

line 78, in <module>    idx = int(i) - 1   # Get the integer location of the index label          ^^^^^^ValueError: invalid literal for int() with base 10: 'delivery date remains 01/13/2025 *smunoz6'

i tried everything and still not worki expect to move the columns to the right place


Viewing all articles
Browse latest Browse all 13921

Trending Articles