Python - Как вы можете построить гистограмму данных? - PullRequest
0 голосов
/ 08 ноября 2019

Я хочу построить гистограмму даты. У меня есть данные pandas:

Creation Date  Profile_ID Count
2016-06-01            150
2016-06-03            3
2016-06-04            20 

Как я могу определить оси x и y моей гистограммы, чтобы у меня был график количества вновь созданных идентификаторов профиля на дату?

Ответы [ 2 ]

1 голос
/ 08 ноября 2019

Попробуйте:

import matplotlib.pyplot as plt
ax = df.plot.bar(y='Profile_ID Count')
plt.show()
0 голосов
/ 08 ноября 2019
# Importing the requisite libraries
import pandas as pd
import matplotlib.pyplot as plt

# Creating the DataFrame
df = pd.DataFrame({'Creation Date':['2016-06-01','2016-06-03','2016-06-04'],'Profile_ID Count':[150,3,20]})

# Creating the bar chart below.
fig, ax = plt.subplots()
ax.bar(df['Creation Date'],df['Profile_ID Count'], color='red', width = 0.5)   
fig.autofmt_xdate()   # This tilts the dates displayed along X-axis.
ax.set_title('Creation Date vs. Profile ID Count')
ax.set_xlabel('Creation Date')
ax.set_ylabel('Profile ID Count')
plt.show()

Bar-Chart

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...