18. Consider the saleDf shown below.
|
Target |
Sales |
ZoneA |
56000 |
58000 |
ZoneB |
70000 |
68000 |
ZoneC |
75000 |
78000 |
ZoneD |
60000 |
61000 |
Write a program to rename indexes of
ZoneC and ZoneD as Central and Dakshin respectively and the column names Target
and Sales as Targeted and Achieved respectively.
import pandas as pd
d={'Target':{'ZoneA':56000,'ZoneB':70000,'ZoneC':75000,'ZoneD':60000},
\
'Sales':
{'ZoneA':58000,'ZoneB':68000,'ZoneC':78000,'ZoneD':61000}}
saleDf=pd.DataFrame(d)
print(saleDf)
salesDf1=saleDf.rename(index={'ZoneC':'Central','ZoneD':'Dakshin'},
\
columns={'Target':'Targeted','Sales':'Achieved'})
print(salesDf1)
========= RESTART: C:/Program Files
(x86)/Python38-32/IP-18.py ========
Target
Sales
ZoneA 56000
58000
ZoneB 70000
68000
ZoneC 75000
78000
ZoneD 60000
61000
Targeted Achieved
ZoneA 56000
58000
ZoneB 70000
68000
Central 75000
78000
Dakshin 60000
61000
>>>
No comments:
Post a Comment