79461737

Date: 2025-02-23 18:14:13
Score: 1
Natty:
Report link

This is another rapid, simple and a bit different way to insert a row in a pandas dataframe at the top :

df.loc[-1] = [2,3,4]
df = df.sort_index().reset_index(drop = True)

and you will have this result :

    A   B   C
0   2   3   4
1   5   6   7
2   7   8   9
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Youssef Zied ELHECHMI