전체 글

전체 글

    [Python] Renaming and Combining

    1. Renaming rename() 은 column name과 index name을 바꿀 수 있다. reviews.rename(columns = {'point' : 'score'}) rename()은 dictionary 형태로 column을 key-value 방식으로 변경한다. 2. Combining 데이터 셋을 합칠려고 할때, concat(), join(), merge() 함수를 통해 데이터를 합친다. 목차\종류 concat() merge() 적용 대상 Series DataFrame 방향 axis(row/column) left, right, outer, inner Source of the course : Kaggle Course _ Renaming and Combining

    [Python] Data Types and Missing Values

    [Python] Data Types and Missing Values

    1. Dtypes column에 대한 데이터 타입을 알고자 한다면, dtype 를 사용한다. reviews.price.dtype # result will be dtype('float64') 모든 column에 대한 dtype를 알고싶다면, dtypes 를 사용한다. reviews.dtypes 데이터 타입은 판다스가 데이터를 어떻게 저장하고 있는지 알 수 있다. 예를들어 'float64'는 64-bit floating 숫자를 이용하고 있다. 2. Missing data 결측값을 가지고 있는 항목은 NaN(Not a Number) 값을 가지고 있다. 기술적 이유로 인해 NaN은 float64 데이터 타입을 가지고 있으며 NaN항목의 값을 isnull()을 통해 검색할 수 있다. reviews[pd.isnul..

    [Python] Grouping and Sorting

    [Python] Grouping and Sorting

    1. Groupwise analysis # working same as value_counts() reviews.groupby('points').points.count() groupby() 함수는 특정한 value에 의해 생성된 그룹을 만든다. 위의 groupby() + count()연산은 value_count()와 동일한 연산을 수행한다. 기존에 사용했던 요약 함수(mean, sum, count, median)를 사용해 grouping을 할 수 있다. 먼저 group의 unique value에 따라 summary function을 적용한 후 다시 합쳐 grouping된 데이터셋을 만든다. reviews.groupby('winery').apply(lambda df : df.title.iloc[0]) 단일..

    [Python] Summary Functions and Maps

    [Python] Summary Functions and Maps

    1. Summary functions reviews.points.describe() # It returns count, mean, min, 25%, 50%(median), 75%, max describe() 함수는 주어진 columns 에 대한 기초통계량을 테이블로 보여준다. # return mean of Series reviews.points.mean() # return unique values of column reviews.taster_name.unique() # return unique values and its count reviews.taster_name.value_counts() 2. Maps 맵(map)이라는 함수는 말 그대로 하나의 값을 다른 값으로 매핑시키는 작업을 수행한다. 데이터 사..