# 특정값 NA로 취급

na_val = {'term' : [36]}
pd.read_csv('example_df.csv', na_values=na_val).head()

# 행 생략
df.head()

pd.read_csv('example_df.csv', skiprows=[1, 2]).head()

# 일부 행만 읽기
df_output = pd.read_csv('example_df.csv', nrows=3)
df_output

# file output
df_output.to_csv('df_output.csv', index=False, header=False)

# 인터넷 csv파일 읽기
ip_data = pd.read_csv('https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/fBasics/data/IP.dat.csv?revision=1&root=rmetrics&pathrev=1', sep=';')
ip_data

"""
Explanation: \d - 숫자
\s - 공백(whitespace)
\w - 문자+숫자(alphanumeric)
\t - tab
\n - 개행문자
End of explanation
"""


import pandas_datareader.data as web
import datetime

start = datetime.datetime(2016, 1, 1)
end = datetime.datetime(2016, 12, 31)
print(start, end)

"""
Explanation: 인터넷 DB 읽기

Yahoo! Finance
Google Finance
St.Louis FED (FRED)
Kenneth French's data library
World Bank

Google Analytics


pip install pandas_datareader
End of explanation
"""


df = web.DataReader('005930.KS', 'yahoo', start, end)
df.tail()

"""
Explanation: http://finance.yahoo.com/q?s=005930.ks
End of explanation
"""


df = web.DataReader('KRX:005930', 'google', start, end)
df.tail()

"""
Explanation: https://www.google.com/finance?cid=151610035517112
End of explanation
"""


df = web.DataReader('GDP', 'fred', start, end)
df

"""
Explanation: https://fred.stlouisfed.org/series/GDP
End of explanation
"""


