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.

5
  • does this helps: stackoverflow.com/questions/55439469/…? Commented Jan 28, 2021 at 9:28
  • stackoverflow.com/questions/46890972/… Commented Jan 28, 2021 at 9:28
  • Can you explain the logic? Are you swapping the two rows within the same dataframe? If yes on what basis? Commented Jan 28, 2021 at 9:31
  • SettingWithCopyWarning is NOT an error. It is merely a warning. Check this out to understand more about this stackoverflow.com/questions/20625582/… Commented Jan 28, 2021 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 Commented Jan 30, 2021 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.