79227280

Date: 2024-11-26 15:20:58
Score: 1
Natty:
Report link

You can shift only the B and C column

import pandas as pd

# Create the DataFrame
data = {
    'A': ['First', 'Second'],
    'B': ['row to delete', 'row to delete'],
    'C': ['row to shift', 'row to shift']
}

df = pd.DataFrame(data)

print(df)

# Shift only the 'B' and 'C' columns
df[['B', 'C']] = df[['B', 'C']].shift(-1, axis=1, fill_value='')


print(df)

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: samhita