Skip to content

Instantly share code, notes, and snippets.

@northface
Last active June 20, 2017 13:23
Show Gist options
  • Save northface/5a2d20770e4b92a4dbbcfa45fc936049 to your computer and use it in GitHub Desktop.
Save northface/5a2d20770e4b92a4dbbcfa45fc936049 to your computer and use it in GitHub Desktop.
pandasで日付の差分を取る方法
dt = pd.datetime.now().date()
df_pic['経験年数'] = ((dt - df_pic['入社日付'].dt.date).dt.days / 365).round(0).astype(int)
df_pic.head()
def graph_histogram(data,title,binwidth=5):
"""
ヒストグラムを描く関数
"""
plt.hist(data, bins=range(0, max(data)+1+ binwidth, binwidth))
plt.title(title)
plt.xlabel("day")
plt.ylabel("Frequency")
plt.xlim([0,25])
plt.ylim([0,20])
plt.show()
return
graph_histogram(df_pic['経験年数'],title="Histogram of keikennensu",binwidth=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment