개발일지/데이터 분석
시계열 데이터 관련 다시보기
shinyfood
2024. 1. 16. 09:07
728x90
반응형
In [1]:
"""
시간단위로 축적되는 데이터를 통한 분석 및 예측할때 사용된다. 향후의 추이를 예측할때 사용.
"시""계열"/시간단위 데이터 축적
"""
Out[1]:
'\n시간단위로 축적되는 데이터를 통한 분석 및 예측할때 사용된다. 향후의 추이를 예측할때 사용.\n"시""계열"/시간단위 데이터 축적\n'
시간데이터 조작¶
In [2]:
import pandas as pd
In [3]:
# [시간 유형] 데이터 만들기
dates = ["2020-01-01", "2020-03-01", "2021-09-01"]
dates
Out[3]:
['2020-01-01', '2020-03-01', '2021-09-01']
In [4]:
"""시간 유형의 문자열을 날짜 타입으로 변환하기(형변환)"""
ts_dates = pd.to_datetime(dates)
ts_dates
Out[4]:
DatetimeIndex(['2020-01-01', '2020-03-01', '2021-09-01'], dtype='datetime64[ns]', freq=None)
In [5]:
# 앞에는 8자리의 날짜, 뒤에는 6자리의 시간// 시분초가 따로 없으면 0시0분0초로 입력됨.
ts_dates[0]
Out[5]:
Timestamp('2020-01-01 00:00:00')
In [6]:
type(ts_dates)
Out[6]:
pandas.core.indexes.datetimes.DatetimeIndex
In [7]:
"""년월일 단위로 추출하기
- to_period() : 날짜 타입의 데이터에서 특정 날짜(년, 월, 일)을 추출하고자 할때 사용
"""
pr_day = ts_dates.to_period(freq="D")
pr_day
Out[7]:
PeriodIndex(['2020-01-01', '2020-03-01', '2021-09-01'], dtype='period[D]')
In [8]:
"""년월 단위로 추출하기"""
pr_month = ts_dates.to_period(freq="M")
pr_month
Out[8]:
PeriodIndex(['2020-01', '2020-03', '2021-09'], dtype='period[M]')
In [9]:
"""년 단위로 추출하기"""
pr_year = ts_dates.to_period(freq="Y")
pr_year
Out[9]:
PeriodIndex(['2020', '2020', '2021'], dtype='period[A-DEC]')
데이터 읽어들이기¶
In [10]:
df = pd.read_csv("./data/timeseries.csv")
df
Out[10]:
Date | Close | Start | High | Low | Volume | |
---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 |
In [11]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Date 5 non-null object
1 Close 5 non-null int64
2 Start 5 non-null int64
3 High 5 non-null int64
4 Low 5 non-null int64
5 Volume 5 non-null int64
dtypes: int64(5), object(1)
memory usage: 368.0+ bytes
In [12]:
"""
- Date 데이터를 날짜타입으로 변경하여, 새로운 컬럼에 넣어주세요.
- 새로운 컬럼 이름 : new_Date
"""
Out[12]:
'\n - Date 데이터를 날짜타입으로 변경하여, 새로운 컬럼에 넣어주세요.\n - 새로운 컬럼 이름 : new_Date\n'
In [13]:
df["Date"]
df["new_Date"] = pd.to_datetime(df["Date"])
In [14]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Date 5 non-null object
1 Close 5 non-null int64
2 Start 5 non-null int64
3 High 5 non-null int64
4 Low 5 non-null int64
5 Volume 5 non-null int64
6 new_Date 5 non-null datetime64[ns]
dtypes: datetime64[ns](1), int64(5), object(1)
memory usage: 408.0+ bytes
In [15]:
### new_Date 컬럼의 0번째 데이터를 추출해주세요...
# - 알고 있는 방법 모두 사용해보세요...
# iloc는 index번호로 뽑기, loc는 우리 눈에보이는 번호로 뽑기
a = df["new_Date"].loc[0]
b = df["new_Date"].iloc[0] # b = df.iloc[0,-1]
c = df["new_Date"][0]
# 수정할때는 iloc나 loc로 접근해서 수정해야함.
In [16]:
df["new_Date"]
Out[16]:
0 2015-07-02
1 2016-06-29
2 2017-06-28
3 2018-06-27
4 2019-06-26
Name: new_Date, dtype: datetime64[ns]
In [17]:
"""
날짜 타입의 컬럼만 남기고, 날짜 유형을 가지는 Date 컬럼을 삭제하기
"""
# df = df.drop("Date", axis=1)
df.drop("Date", axis=1, inplace=True)
df
Out[17]:
Close | Start | High | Low | Volume | new_Date | |
---|---|---|---|---|---|---|
0 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015-07-02 |
1 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016-06-29 |
2 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017-06-28 |
3 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018-06-27 |
4 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019-06-26 |
In [18]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Close 5 non-null int64
1 Start 5 non-null int64
2 High 5 non-null int64
3 Low 5 non-null int64
4 Volume 5 non-null int64
5 new_Date 5 non-null datetime64[ns]
dtypes: datetime64[ns](1), int64(5)
memory usage: 368.0 bytes
In [19]:
"""
- 시계열 분석을 위해서는
→ index를 날짜 타입의 데이터로 사용해야 함
- new_Date 컬럼의 데이터를 인덱스로 사용하게 해주세요
"""
Out[19]:
'\n - 시계열 분석을 위해서는\n → index를 날짜 타입의 데이터로 사용해야 함\n - new_Date 컬럼의 데이터를 인덱스로 사용하게 해주세요\n'
In [20]:
df.set_index("new_Date", inplace=True)
df
Out[20]:
Close | Start | High | Low | Volume | |
---|---|---|---|---|---|
new_Date | |||||
2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 |
2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 |
2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 |
2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 |
2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 |
In [21]:
df.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 5 entries, 2015-07-02 to 2019-06-26
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Close 5 non-null int64
1 Start 5 non-null int64
2 High 5 non-null int64
3 Low 5 non-null int64
4 Volume 5 non-null int64
dtypes: int64(5)
memory usage: 240.0 bytes
기간 설정하기¶
In [22]:
"""
* 기간 설정하는 함수 : pd.date_range()
- start : 설정 기간의 시작 값.
- end : 설정 기간의 끝 값(None은 무한대)
- periods : 생서할 기간의 개수
- freq : 시간 간격 설정(Y는 년도, M은 월, D는 일 등) (Y앞에 숫자를 붙이면 증가시키는 수를 변경 가능.)
- tz : 타임존(사용할 국가 지정)
* 아래 함수 해석
- 2020년 1월1일을 시작값으로,
- 종료값 없이, 6개의 구간값을 출력
- 시간 간격은 Y(년도)를 기준으로 1씩 증가시키고,
- 사용할 시간은 한국시간 사용
"""
timestamp_df = pd.date_range(start="2020-01-01",
end=None,
periods=6,
freq="Y",
tz="Asia/Seoul")
timestamp_df
Out[22]:
DatetimeIndex(['2020-12-31 00:00:00+09:00', '2021-12-31 00:00:00+09:00',
'2022-12-31 00:00:00+09:00', '2023-12-31 00:00:00+09:00',
'2024-12-31 00:00:00+09:00', '2025-12-31 00:00:00+09:00'],
dtype='datetime64[ns, Asia/Seoul]', freq='A-DEC')
In [23]:
"""
3년단위로 기간 구성하기, 6개 기간 추출하기
"""
timestamp_df3 = pd.date_range(start="2010-01-01",
end = None,
periods=6,
freq="3Y",
tz="Asia/Seoul")
# timestamp_df3 = pd.date_range(start="2010-01-01",
# end = None,
# periods=6,
# freq="3Y") 이러면 시간이 안붙는다.
timestamp_df3
Out[23]:
DatetimeIndex(['2010-12-31 00:00:00+09:00', '2013-12-31 00:00:00+09:00',
'2016-12-31 00:00:00+09:00', '2019-12-31 00:00:00+09:00',
'2022-12-31 00:00:00+09:00', '2025-12-31 00:00:00+09:00'],
dtype='datetime64[ns, Asia/Seoul]', freq='3A-DEC')
In [24]:
"""
2개월 단위로 기간을 설정해보기. 기간은 3개 추출
"""
pd.date_range(start="2024-01-01",
end = None,
periods=3,
freq="2M")
Out[24]:
DatetimeIndex(['2024-01-31', '2024-03-31', '2024-05-31'], dtype='datetime64[ns]', freq='2M')
In [25]:
"""
3일 단위로 6개의 기간 추출하기
"""
pd.date_range(start="2024-01-01",
end = None,
periods = 6,
freq = "3D")
Out[25]:
DatetimeIndex(['2024-01-01', '2024-01-04', '2024-01-07', '2024-01-10',
'2024-01-13', '2024-01-16'],
dtype='datetime64[ns]', freq='3D')
In [26]:
"""
2시간 단위로 4개 기간 추출하기
"""
pd.date_range(start="2020-01-01",
end = None,
periods = 4,
freq = "2H")
Out[26]:
DatetimeIndex(['2020-01-01 00:00:00', '2020-01-01 02:00:00',
'2020-01-01 04:00:00', '2020-01-01 06:00:00'],
dtype='datetime64[ns]', freq='2H')
In [27]:
"""3분단위로 5개 기간 추출하기"""
pd.date_range(start="2020-01-01",
end=None,
periods=5,
freq="3min")
Out[27]:
DatetimeIndex(['2020-01-01 00:00:00', '2020-01-01 00:03:00',
'2020-01-01 00:06:00', '2020-01-01 00:09:00',
'2020-01-01 00:12:00'],
dtype='datetime64[ns]', freq='3T')
In [28]:
"""2초간격으로 3개 기간 추출하기"""
pd.date_range(start="2020-01-01",
end = None,
periods=3,
freq="2s")
Out[28]:
DatetimeIndex(['2020-01-01 00:00:00', '2020-01-01 00:00:02',
'2020-01-01 00:00:04'],
dtype='datetime64[ns]', freq='2S')
In [29]:
"""
2일 2시간 2분 2초 간격으로 5개 기간을 추출해 주세요
"""
pd.date_range(start="2020-01-01",
end = None,
periods= 5,
freq="2D2H2min2s")
# 달력은 파이썬으로 만드는게 편하다.
Out[29]:
DatetimeIndex(['2020-01-01 00:00:00', '2020-01-03 02:02:02',
'2020-01-05 04:04:04', '2020-01-07 06:06:06',
'2020-01-09 08:08:08'],
dtype='datetime64[ns]', freq='180122S')
In [30]:
df.reset_index(inplace=True)
In [32]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 new_Date 5 non-null datetime64[ns]
1 Close 5 non-null int64
2 Start 5 non-null int64
3 High 5 non-null int64
4 Low 5 non-null int64
5 Volume 5 non-null int64
dtypes: datetime64[ns](1), int64(5)
memory usage: 368.0 bytes
In [60]:
"""
new_Date 컬럼에서 "년도"만 추출하기
- 데이터프레임 안에 특정 날짜 타입의 컬럼에서 각 값 년/월/일을 추출/변경할 경우에는
→ 각 값에 접근해야 합니다.
- 클래스 뒤의 "." 은 접근지정자라고 합니다.
"""
df["Year"] = df["new_Date"].dt.year
df
Out[60]:
new_Date | Close | Start | High | Low | Volume | Year | |
---|---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019 |
In [61]:
df["Month"] = df["new_Date"].dt.month
df
Out[61]:
new_Date | Close | Start | High | Low | Volume | Year | Month | |
---|---|---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015 | 7 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016 | 6 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017 | 6 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018 | 6 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019 | 6 |
In [62]:
df["Day"] = df["new_Date"].dt.day
df
Out[62]:
new_Date | Close | Start | High | Low | Volume | Year | Month | Day | |
---|---|---|---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015 | 7 | 2 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016 | 6 | 29 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017 | 6 | 28 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018 | 6 | 27 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019 | 6 | 26 |
In [63]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 9 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 new_Date 5 non-null datetime64[ns]
1 Close 5 non-null int64
2 Start 5 non-null int64
3 High 5 non-null int64
4 Low 5 non-null int64
5 Volume 5 non-null int64
6 Year 5 non-null int32
7 Month 5 non-null int32
8 Day 5 non-null int32
dtypes: datetime64[ns](1), int32(3), int64(5)
memory usage: 428.0 bytes
In [97]:
"""
new_Date 컬럼의 데이터를 이용해서, 0000-00(년-월) 단위로 추출하여, YM 컬럼 생성하기
M은 년월까지 다 뽑기 때문에 M을 뽑으면 된다.
"""
df["YM"] = df["new_Date"].dt.to_period(freq="M")
In [100]:
df["YMD"] = df["new_Date"].dt.to_period(freq="D")
In [101]:
df
# 이런식으로 만든다음 년월일로할건지 년월로 할건지에 따라 사용하면 된다.
Out[101]:
new_Date | Close | Start | High | Low | Volume | Year | Month | Day | YM | YMD | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015 | 7 | 2 | 2015-07 | 2015-07-02 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016 | 6 | 29 | 2016-06 | 2016-06-29 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017 | 6 | 28 | 2017-06 | 2017-06-28 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018 | 6 | 27 | 2018-06 | 2018-06-27 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019 | 6 | 26 | 2019-06 | 2019-06-26 |
In [102]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 11 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 new_Date 5 non-null datetime64[ns]
1 Close 5 non-null int64
2 Start 5 non-null int64
3 High 5 non-null int64
4 Low 5 non-null int64
5 Volume 5 non-null int64
6 Year 5 non-null int32
7 Month 5 non-null int32
8 Day 5 non-null int32
9 YM 5 non-null period[M]
10 YMD 5 non-null period[D]
dtypes: datetime64[ns](1), int32(3), int64(5), period[D](1), period[M](1)
memory usage: 508.0 bytes
In [107]:
"""new_Date 컬럼을 인덱스로 지정하기"""
df.set_index("new_Date", inplace=True)
df
Out[107]:
Close | Start | High | Low | Volume | Year | Month | Day | YM | YMD | |
---|---|---|---|---|---|---|---|---|---|---|
new_Date | ||||||||||
2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015 | 7 | 2 | 2015-07 | 2015-07-02 |
2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016 | 6 | 29 | 2016-06 | 2016-06-29 |
2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017 | 6 | 28 | 2017-06 | 2017-06-28 |
2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018 | 6 | 27 | 2018-06 | 2018-06-27 |
2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019 | 6 | 26 | 2019-06 | 2019-06-26 |
In [108]:
df.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 5 entries, 2015-07-02 to 2019-06-26
Data columns (total 10 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Close 5 non-null int64
1 Start 5 non-null int64
2 High 5 non-null int64
3 Low 5 non-null int64
4 Volume 5 non-null int64
5 Year 5 non-null int32
6 Month 5 non-null int32
7 Day 5 non-null int32
8 YM 5 non-null period[M]
9 YMD 5 non-null period[D]
dtypes: int32(3), int64(5), period[D](1), period[M](1)
memory usage: 380.0 bytes
In [142]:
"""
df 데이터프레임의 0번째 행의 값을 추출해주세요
- 추출하는 방법 모두 사용..
"""
df.iloc[0]
df.loc["2015-07-02"]
### 인덱스가 RangeIndex가 아니면 직접 접근이 안됨(오류 발생)
# - loc 또는 iloc를 사용해야 함.
# df["2015-07-02"]
# df[0]
Out[142]:
Close 10100
Start 10850
High 10900
Low 10000
Volume 137977
Year 2015
Month 7
Day 2
YM 2015-07
YMD 2015-07-02
Name: 2015-07-02 00:00:00, dtype: object
In [158]:
"인덱스 2016:06-29 ~ 2018-06-27까지의 행 조회하기"
df.iloc[1:4]
df.loc["2016-06-29" : "2018-06-27"]
df[1:4]
Out[158]:
Close | Start | High | Low | Volume | Year | Month | Day | YM | YMD | |
---|---|---|---|---|---|---|---|---|---|---|
new_Date | ||||||||||
2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016 | 6 | 29 | 2016-06 | 2016-06-29 |
2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017 | 6 | 28 | 2017-06 | 2017-06-28 |
2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018 | 6 | 27 | 2018-06 | 2018-06-27 |
In [166]:
""" df 변수로 csv 파일 새로 불러들이고,
new_Date 컬럼 생성: Date 컬럼을 날짜타입으로 변환해서 사용
"""
df = pd.read_csv("./data/timeseries.csv")
df
Out[166]:
Date | Close | Start | High | Low | Volume | |
---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 |
In [171]:
df["new_Date"] = pd.to_datetime(df["Date"])
df
Out[171]:
Date | Close | Start | High | Low | Volume | new_Date | |
---|---|---|---|---|---|---|---|
0 | 2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 | 2015-07-02 |
1 | 2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 | 2016-06-29 |
2 | 2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 | 2017-06-28 |
3 | 2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 | 2018-06-27 |
4 | 2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 | 2019-06-26 |
In [173]:
df.set_index("new_Date", inplace=True)
In [191]:
df.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 5 entries, 2015-07-02 to 2019-06-26
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Close 5 non-null int64
1 Start 5 non-null int64
2 High 5 non-null int64
3 Low 5 non-null int64
4 Volume 5 non-null int64
dtypes: int64(5)
memory usage: 240.0 bytes
In [175]:
df.drop("Date", axis=1, inplace=True)
df
Out[175]:
Close | Start | High | Low | Volume | |
---|---|---|---|---|---|
new_Date | |||||
2015-07-02 | 10100 | 10850 | 10900 | 10000 | 137977 |
2016-06-29 | 10700 | 10550 | 10900 | 9990 | 170253 |
2017-06-28 | 10400 | 10900 | 10950 | 10150 | 155769 |
2018-06-27 | 10900 | 10800 | 11050 | 10500 | 133548 |
2019-06-26 | 10800 | 10900 | 11000 | 10700 | 63039 |
In [176]:
import matplotlib.pyplot as plt
import seaborn as sns
In [241]:
"""
x축 : 인덱스 값
y축 : 각각 컬럼의 범위 값으로
각 컬럼에 대한 선그래프 그리기
- 그래프 하나에 모든 컬럼의 선 그래프 표현
"""
df.plot(marker="h")
plt.title("all-df")
plt.xlabel("year")
plt.ylabel("range")
plt.grid()
plt.show()
In [239]:
plt.figure(figsize=(7,4))
plt.plot(df.index, df.iloc[:,:5], marker=".")
plt.title("all-df")
plt.legend(df.keys())
plt.grid()
plt.xlabel("date")
plt.ylabel("values")
plt.xticks(rotation=90)
plt.show()
728x90
반응형