'Plot histogram from two columns of csv using pandas

I have a csv file containing two columns. What I'd like to do is to plot a histogram based on these two columns.

My code is as follows:

data = pd.read_csv('data.csv')

My csv data is made like this:

Age     Blood Pressure
51           120
..           ...

I tried with plt.hist(data['Age'], bins=10) which only gives me an histogram based on the first column and its frequency, the same goes for the second column. Is there a way to plot an histogram which shows me "Ages" in the x-Axis and "Blood Pressure" in the y-Axis?



Solution 1:[1]

If it actually makes sense for you, you can change the orientation of the second plot:

plt.hist(data['Age'], bins=10, alpha=.5)
plt.hist(data['Blood Pressure'], bins=10, alpha=.5, orientation='horizontal')
plt.show()

Solution 2:[2]

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.bar(data['Age'], data['Blood Pressure'])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CainĂ£ Max Couto-Silva
Solution 2 Craving_gold