Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

01%20python/04.08%20%EC%8B%9C%EA%B3%84%EC%97%B4%20%EC%9E%90%EB%A3%8C%20%EB%8B%A4%EB%A3%A8%EA%B8%B0 #60

Open
utterances-bot opened this issue May 19, 2022 · 3 comments

Comments

@utterances-bot
Copy link

4.8 시계열 자료 다루기 — 데이터 사이언스 스쿨

http://datascienceschool.net/01%20python/04.08%20%EC%8B%9C%EA%B3%84%EC%97%B4%20%EC%9E%90%EB%A3%8C%20%EB%8B%A4%EB%A3%A8%EA%B8%B0.html

Copy link

4.8.1

s = df["date"].squeeze()
df_m = s.dt.month.to_frame()
df_m.rename(columns={'date':'month'}, inplace=True)
#df_m

df2 = pd.concat([df, df_m], axis=1)
#df2
df2.value.groupby(df2.month).sum()

Copy link

np.random.seed(0)
df=pd.DataFrame({
'date': pd.date_range('2020-12-25',periods=100,freq='D'),
'value': np.random.randint(100,size=(100,))})
df.set_index('date')
df['month']=df['date'].dt.month
df.groupby('month')['value'].sum()

Copy link

df.groupby(df["date"].dt.month).sum()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants