79742259

Date: 2025-08-21 12:10:20
Score: 0.5
Natty:
Report link

I had a task to create a row by the next index after the last one, adding a value only to the first field and automatically setting nan to the rest of the fields. I solved it like this:

df1.loc[df1.index[-1] + 1] = ['2025-08-01' if i == 0 else np.nan for i in range(len(list(df1)))]

Reasons:
  • Whitelisted phrase (-2): I solved
  • Low length (0.5):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: MikhailRuss