Q04 Pandas DataFrame 에 있는 column 이름 변경¶ In [1]: import pandas as pd In [2]: ufo = pd.read_csv('http://bit.ly/uforeports') In [4]: ufo.head() Out[4]: City Colors Reported Shape Reported State Time 0 Ithaca NaN TRIANGLE NY 6/1/1930 22:00 1 Willingboro NaN OTHER NJ 6/30/1930 20:00 2 Holyoke NaN OVAL CO 2/15/1931 14:00 3 Abilene NaN DISK KS 6/1/1931 13:00 4 New York Worlds Fair NaN LIGHT NY 4/18/193..
Q03 pandas 커맨드 중 괄호() 로 끝나는 것과 그렇지 않은 것¶ In [1]: import pandas as pd In [3]: movies = pd.read_csv('http://bit.ly/imdbratings') In [4]: movies.head() Out[4]: star_rating title content_rating genre duration actors_list 0 9.3 The Shawshank Redemption R Crime 142 [u'Tim Robbins', u'Morgan Freeman', u'Bob Gunt... 1 9.2 The Godfather R Crime 175 [u'Marlon Brando', u'Al Pacino', u'James Caan'] 2 9.1 Th..
pandas 데이터 프레임에서 시리즈를 얻어 내는 방법¶ pandas 에는 두가지 기본적인 object type 이 있다¶하나는 dataframe 이고 raw 와 column 으로 이루어진 table 형태의 data 하나는 series 이다. dataframe 의 각 column 은 pandas 의 series 로 이루어져있다. In [3]: import pandas as pd In [4]: ufo = pd.read_csv('http://bit.ly/uforeports') In [5]: type(ufo) Out[5]: pandas.core.frame.DataFrame In [6]: ufo.head() Out[6]: City Colors Reported Shape Reported State ..
표 읽어 오기¶ In [2]: import pandas as pd In [5]: orders =pd.read_table('http://bit.ly/chiporders') In [7]: orders.head() Out[7]: order_id quantity item_name choice_description item_price 0 1 1 Chips and Fresh Tomato Salsa NaN $2.39 1 1 1 Izze [Clementine] $3.39 2 1 1 Nantucket Nectar [Apple] $3.39 3 1 1 Chips and Tomatillo-Green Chili Salsa NaN $2.39 4 2 2 Chicken Bowl [Tomatillo-Red Chili S..
180607_datetime Python 표준 라이브러리로서 datetime 모듈 사용¶ In [1]: from datetime import datetime In [2]: now = datetime.now() In [3]: now Out[3]: datetime.datetime(2018, 6, 7, 21, 28, 50, 734895) In [4]: now.year, now.month, now.day, now.date Out[4]: (2018, 6, 7, ) datetime.timedelta datetime 객체 간의 시간적인 차이¶ In [5]: delta = datetime.now() - datetime(2011,10,10) In [6]: delta Out[6]: datetime.timedelta(243..