본문 바로가기

프로그래머스 데브 코스/TIL

[6기] 프로그래머스 인공지능 데브코스 8일차 TIL

0908

3주차-Day5) Matlab 과제

넷플릭스 데이터 활용

import pandas as pd
import numpy as np

net = pd.read_csv("netflix_titles.csv")

k_net = net["country"][net["country"] == 'South Korea']
k_net.count()   # 한국 작품 개수
import pandas as pd
import numpy as np

net = pd.read_csv("netflix_titles.csv")

net["country"].value_counts().head(1)   # 가장 많은 작품이 올라간 국가
max(net["country"].value_counts())      # 작품 개수

 

비트코인/이더리움 데이터 활용

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

bit = pd.read_csv("BitCoin.csv")                                               # 비트코인 그래프 
new_bit = bit[(bit["Date"] >= "2016-06-01") & (bit["Date"] <= "2017-06-30")]   # 필요한 기간 데이터만 모으기 
new_bit = new_bit.sort_values(by='Date')                                       # 기간 기준으로 재배열
new_bit["5MA"] = new_bit["Open"].rolling(window=5).mean()                      # 5일 단위 "Open"의 평균값으로 "5MA" 열 생성

plt.figure(figsize = (10, 4))
plt.plot(new_bit["Date"], new_bit["5MA"], color="#f2a900")
plt.xticks(ticks = new_bit["Date"].to_list(), labels=new_bit["Date"], rotation=45)   # 그래프 x축 눈금 정리
plt.xlabel("Date")
plt.ylabel("Price")
plt.title("5-MA(Moving Average) Price of Bitcoin")
plt.locator_params(axis='x', nbins=len(new_bit["Date"])/30)                          # 그래프 x축 텍스트 출력 빈도 지정
plt.show()
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

bit = pd.read_csv("BitCoin.csv")                                               # 비트코인 그래프 
new_bit = bit[(bit["Date"] >= "2016-06-01") & (bit["Date"] <= "2017-06-30")]   # 필요한 기간 데이터만 모으기 
new_bit = new_bit.sort_values(by='Date')                                       # 기간 기준으로 재배열
new_bit["5MA"] = new_bit["Open"].rolling(window=5).mean()                      # 5일 단위 "Open"의 평균값으로 "5MA" 열 생성

eth = pd.read_csv("ETH_day.csv")                                               # 이더리움 그래프 
new_eth = eth[(eth["Date"] >= "2016-06-01") & (eth["Date"] <= "2017-06-30")]
new_eth = new_eth.sort_values(by='Date')
new_eth["5MA"] = new_eth["Open"].rolling(window=5).mean()

plt.figure(figsize = (10, 4))
plt.plot(new_eth["Date"], new_eth["5MA"], color="#3c3c3d", label="ETH")
plt.plot(new_bit["Date"], new_bit["5MA"], color="#f2a900", label="BitCoin")
plt.xticks(ticks = new_bit["Date"].to_list(), labels=new_bit["Date"], rotation=45)   # 그래프 x축 눈금 정리
plt.xlabel("Date")
plt.ylabel("Price")
plt.title("5-MA(Moving Average) Price of Bitcoin")
plt.locator_params(axis='x', nbins=len(new_bit["Date"])/30)                          # 그래프 x축 텍스트 출력 빈도 지정
plt.legend()
plt.show()