I have extracted a dataframe of n columns, where the first column is the index column with no header followed by pairs of "success" and "fail" columns. I managed to extract the success only columns and place a header on the index column with this code:
df2 = df1.iloc[:,0::2]
df3 = df2
df3.reset_index(inplace=True)
df4 = df3.rename(columns = {'index':'out_date'})
df4
Output of the code can be found here
I would like to sort the "out_date" column in ascending order using sort_values but for that to work, the "success" columns need to be unique. I have this line of code that is able to rename the headers to "success1", "success2", "success3",..., but I can't figure out how to exclude the "out_date" column.
numcolumn = df4.shape[1]
df4.columns = ["success"+str(x) for x in range(1,numcolumn+1)]
df4
Any help given will be appreciated. Thank you.