Reputation: 25
First DataFrame : prac1 and second one : prac_dates
After writing the following code it gives the userwarning:
pracs = prac_dates.join(prac1,how='inner',on = "Month")
What I wish to achieve is to
1)Remove the user warning and reorder the column sequence to ('Month','ShipName','ComoQty')and,
2) Rename the (shipname,01),(shipname,02)... column to (shipcount,01),(shipcount,02)...
Upvotes: 0
Views: 94
Reputation: 2190
import warnings
# ignore user warning
warnings.simplefilter(action='ignore', category=UserWarning)
pandas
;>>> df.columns
['wrong', 'order', 'columns']
>>> df = df['order', 'wrong', 'columns']
>>> df.columns
['order', 'wrong', 'columns']
>>> df.columns = ['new', 'column', 'names']
>>> df.columns
['new', 'column', 'names']
Edit:
To answer your question specifically, I gather that you just want to replace shipname
with shipcount
;
df.columns = [col.replace('shipname', 'shipcount') for col in df.columns]
Upvotes: 1