mask = pd.to_numeric(df['Name'], errors='coerce').notnull() df[mask] = df[mask].shift(axis=1) print (df) Name Val Rating 0 ABC 123 B + 1 DEF 234 B + 2 NaN 567 B- 3 GHI 890 D
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter