'Restricting multiple-indexes/header to one column using pandas
Following code gives me header= Rice in every column. I wan to restrict it to only column 0 or the first column and put all other as blank. Basically I want to get rid off repetition of "Rice". Please check the attached picture of the data frame
header = pd.MultiIndex.from_product([['Rice'],["Centre","Feb 2020","Mar 2020","Apr 2020","Average" ]], names=['commo',''])
df=pd.DataFrame(columns=header,data=np.random.randn(6, 5))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|