0

I have created a python code, which scraps data from the web and gets the raw data and then I interpolate between data to get new data and add as a new column.

But while adding the column into the existing data frame I would need to compare the column heading with the new column heading and then insert it before or after.

Example:

If column A heading name is 1 and column B heading name is 3 and my new created column heading name is 2 and I need to check if 2 is less the column A and greater than Column B and then insert the new column between A and B.

Note: I don't want to compare the values in the corresponding column but I need to compare between column heading names (logical operation) and then insert the column accordingly.

Shaido
  • 27,497
  • 23
  • 70
  • 73
  • 1
    Could you add some example input / expected output? See https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Shaido Nov 05 '21 at 09:44
  • list(df) and df.columns.tolist() both give a list of colum names. You can do comparisons on the list elements. – Jonathan Leon Nov 06 '21 at 02:59

0 Answers0