1
ii=0 ...jj=0 ...for i, row in new_df.iterrows():
z=len(row)-1
k=row
ii=ii+1
jj=0
##print(k.iloc[0])
for j, column in row.iteritems():
    z=z-1
    jj=jj+1
    if z>23:
        new_df.loc[ii][jj],k.iloc[z]=k.iloc[z],new_df.iloc[ii][jj]

I have tried running it but it is giving error ...

:13: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation.

yudhiesh
  • 6,383
  • 3
  • 16
  • 49
  • does this helps: https://stackoverflow.com/questions/55439469/swapping-two-rows-together-with-index-within-the-same-pandas-dataframe? – Pygirl Jan 28 '21 at 09:28
  • https://stackoverflow.com/questions/46890972/swapping-rows-within-the-same-pandas-dataframe – Pygirl Jan 28 '21 at 09:28
  • Can you explain the logic? Are you swapping the two rows within the same dataframe? If yes on what basis? – Pygirl Jan 28 '21 at 09:31
  • SettingWithCopyWarning is NOT an error. It is merely a warning. Check this out to understand more about this https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas – mightyandweakcoder Jan 28 '21 at 10:38
  • The values of specific row need to be reversed. Eg- 2 6 4 2 9 7 is going to be 7 9 2 4 6 2 – ABHISHEK BHADAURIA Jan 30 '21 at 15:07

0 Answers0