| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 개발자
- 주가하락
- 함수
- 트위터
- pandas
- 라이브러리설치
- 퀀트투자
- 가치투자
- 보조지표
- 우분투
- 파이썬
- 변동성
- 고등퀀트
- 차트분석
- cloud
- ubuntu
- 이동평균
- 자동트윗
- 클라우드
- 오라클
- 주가상승
- python
- 직장인파이썬
- 크롤링
- dataframe
- 주식투자
- Firewall
- 오라클클라우드
- 단기투자
Archives
- Today
- Total
주경야매 미국주식
시계열데이터에서 데이터 생성 빈도 알아내기 본문
외부에서 가져온 시계열 데이터를 이용할 때, 데이터 생성 빈도를 알아내고 싶은 경우가 있다.
이럴땐 pandas 에서 제공하는 infer_freq() 함수를 이용하자.
pandas.infer_freq(index, warn=True)
주어진 데이터를 이용해 가장 근접한 빈도를 추측한다. 추측이 불가할 경우 warning이 출력된다.
Inputs
- index: 시계열데이터. Series인 경우 인덱스가 아닌 밸류를 사용.
- warn: bool, default True.
Returns
str or None (빈도 추측이 불가할 경우 None)
Errors
TypeError: 입력값이 날짜 형식이 아닌 경우
ValueError: 입력값이 3개 미만인 경우
예제
>>> idx = pd.date_range(start='2020/12/01', end='2020/12/30', periods=30)
>>> pd.infer_freq(idx)
'D'
결과값은 다음과 같이 해석하면 된다.
| B | business day frequency |
| C | custom business day frequency |
| D | calendar day frequency |
| W | weekly frequency |
| M | month end frequency |
| SM | semi-month end frequency (15th and end of month) |
| BM | business month end frequency |
| CBM | custom business month end frequency |
| MS | month start frequency |
| SMS | semi-month start frequency (1st and 15th) |
| BMS | business month start frequency |
| CBMS | custom business month start frequency |
| Q | quarter end frequency |
| BQ | business quarter end frequency |
| QS | quarter start frequency |
| BQS | business quarter start frequency |
| A, Y | year end frequency |
| BA, BY | business year end frequency |
| AS, YS | year start frequency |
| BAS, BYS | business year start frequency |
| BH | business hour frequency |
| H | hourly frequency |
| T, min | minutely frequency |
| S | secondly frequency |
| L, ms | milliseconds |
| U, us | microseconds |
| N | nanoseconds |
'파이썬' 카테고리의 다른 글
| 파이썬의 함수 (0) | 2022.06.22 |
|---|---|
| 데이터프레임에서 인덱스값을 기준으로 최종 열을 뽑을때 (0) | 2022.06.16 |
| nginx 설치, 오라클 클라우드 (5) (0) | 2021.11.29 |
| 서버 방화벽 개방, 오라클 클라우드 (4) (246) | 2021.11.29 |
| 웹서버용 방화벽 설정, 오라클 클라우드 (3) (0) | 2021.11.29 |
Comments