Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # define function to swap columns
- def swap_columns(df, col1, col2):
- col_list = list(df.columns)
- x, y = col_list.index(col1), col_list.index(col2)
- col_list[y], col_list[x] = col_list[x], col_list[y]
- df = df[col_list]
- return df
- #swap points and rebounds columns
- all_ads_until_10_Oct = swap_columns(all_ads_until_10_Oct, 'Company', 'Location')
- all_ads_until_10_Oct
- ######################################################
- # move column to specific place
- column_to_move = df_jobs.pop("Date")
- df_jobs.insert(0, "Date", column_to_move )
- ######################################################
- replace the last column into index 1
- df_auto = df_auto[['Model', 'Price BGN', 'Year', 'Kilometers', 'Transmission', 'Engine_type', 'Horsepower',
- 'Date']]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement