You can use the pandas.DataFrame.rename()
method along with a dictionary to rename the columns based on a condition. Here is an example:
main.py508 chars21 lines
Output:
main.py176 chars5 lines
In this example, the condition is checking whether 'col2' is present in the column name. You can modify the condition based on your specific requirement.
gistlibby LogSnag