2
매월 원시 데이터를 나타내는 상자가있는 시간 지정 데이터의 상자 그림을 만들어야합니다. 이런 식으로 뭔가 : 이제팬더 DataFrame에서 월 단위로 행을 그룹화하려면 어떻게해야합니까?
은의 그 사용 팬더 만들려고하자 :
matplotlib inline
import numpy as np
import pandas as pd
N_DAYS = 100
dates = pd.date_range('20130101', periods=N_DAYS)
df = pd.DataFrame(np.random.randn(N_DAYS,1), index=dates)
나는 달 (코드 M
)에 의해 재 샘플링 할 수 있습니다 및 집계 기능을 적용 같은 median
등 :
df.resample('M').median()
그러나 데이터의 상자 그림을 만들 수 없습니다.
df.resample('M').boxplot();
이렇게하면 각 달의 평균 분포를 나타내는 상자 하나가 만들어집니다.
FutureWarning:
.resample() is now a deferred operation
You called boxplot(...) on this deferred object which materialized it into a dataframe
by implicitly taking the mean. Use .resample(...).mean() instead
이 어떻게 매월 원시 데이터의 상자 그림을 만들려면 어떻게해야합니까 :
또한, 나는 다음과 같은 경고를 얻을? 또한 docs을 확인할 수 있습니다
df['per'] = df.index.to_period('M')
df.boxplot(by='per')
: