A sample input data frame
import pandas as pd
df_input = pd.DataFrame([[1.7, 0.2], [0.4, 0.93], [0.05, 0.96], [0.97, 0.68]], columns=["A", "B"])
This example has two columns whereas the real dataframe has 10. I want to sort each row in ascending order and then assign -1 to first 5 columns and +1 to next 5 columns. Sample output is as follows:-
df_output=pd.DataFrame([[1, -1], [-1, 1], [-1, 1], [1, -1]], columns=["A", "B"])
Please suggest the way forward.