This isn't utterly important though, and I'm just trying to learn using python, and the actual work has been done in excel. I have come across a few other posts related to this issue, but not seen one that specifically addresses the renaming of individual labels. ![]() This is the error I get when using the above code.ĪttributeError: 'Series' object has no attribute 'set_ylabel' I have tried to rename the x-axis labels using the code below. There is a Pandas dataframe: hotelsrev df1'date', 'hotel', 'revenue', 'avrevenue', 'difference', 'inpercent'.sortvalues(by'hotel', 'date') Construct a bar graph with 'hotel' values in the x axis and change values in the 'date' column and 'avrevenue' values in the y axis generate-function null Generate code just by typing a text description. Pd.set_option('display.mpl_style', 'default')įixed_data = pd.read_csv('audit-rep.csv',sep=',',encoding='latin1',index_col='Index', parse_dates=,dayfirst=False) This is the code I have used, and except for the label names, I am happy with the result. Instead of having these verbose reasons though, I would like to rename the X-Axis labels to just numbers or alphabets so that the graph reads somewhat like this: Vendor Registration not on record.another 300 words - 9.No contract with vendor.another 300 words - 14.Not approved by regional committee.another 300 words - 17.But again, it can also rename the row labels (i.e., the labels in the dataframe index). This technique is most often used to rename the columns of a dataframe (i.e., the variable names). ![]() The problem I am facing is renaming the X-Axis labels.Įssentially, the chart is trying to plot a count of different types of Audit Violations, but has really long descriptions of the said violations. You can do it all using the ax variable: ax df.A.plot () ax.setxticks (df.index) ax.setxticklabels (df.C, rotation90) but, as I mentioned, I haven't found a way to the xticklabels inside the df.plot () function parameters, which would make it possible to do this all in a single line. The Pandas rename method is fairly straight-forward: it enables you to rename the columns or rename the row labels of a Python dataframe. I have a CSV file that I am trying to read using Python, and looking to come up with charts. ![]() I'm running my code on iPython Notebooks, on a Macbook Pro Yosemite 10.10.4
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |