I have a csv files with a table of info, I need to plot a hist with the information available, the table has dates and numbers, I want the dates to be on the x axis and the numbers on the y axis, but it is plotting the other way around, below are the details:
The below table is on a csv file (called Results.csv in the below code) that I am reading from, so it has 3 columns, index, Date, and Incidents
Date Incidents
0 14-06-17 637
1 15-06-17 549
2 16-06-17 510
3 17-06-17 460
4 18-06-17 431
5 19-06-17 332
6 20-06-17 220
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
Results_Hist = pd.read_csv ("/content/drive/MyDrive/Colab Notebooks/Results.csv")
hist = Results_Hist['Incidents'].hist()
Please keep in mind that I still want to have it vertical, so again, the dates on the bottom, and the values on the y axis
Also, I don't know why the dates are changing to numbers from 0 to 2 Thanks
CodePudding user response:
Ali, what you want is not a histogram but rather a bar-chart. Histogram will collapse similar values to a single bin, showing you the frequency on the y-axis (that is why you see most of your value with frequency 1, and only one bin contains 2 observations) while - as I understood from your description - you want to display a value for each day separately, right?
If so, do this:
Results_Hist.plot(x='Date', y='AIncidents', kind='bar')