-
pandas.DataFrame.replace, where, mask데이터 분석/Pandas 2022. 5. 24. 08:56
클러스터링 기법을 사용하기 위해 index 에 대한 피쳐를 붙인다. (결과: cluster_df) 이 때, replace 함수가 필요하다. number_of_order_per_CID = order_df.drop_duplicates( subset=['CustomerID', 'InvoiceNo'] )['CustomerID'].value_counts() # CustomerID 를 index 로 하는 Series cluster_df['주문횟수'] = cluster_df['CustomerID'].replace( number_of_order_per_CID.to_dict()) # CustomerID 를 CustomerID 의 주문횟수 값으로 치환 # 매칭되는 것이 없다면 CustomerID 값 유지 cluster_d..
-
Pandas 데이터 먼징 실습 1 - Null/Outlier 처리 및 데이터타입 변환데이터 분석/Pandas 2020. 8. 24. 11:44
이 글은 p. 202 에 포함되어 있는 출생률 데이터 를 기준으로 작업한 것입니다. 포스트에서 사용되는 데이터는 주피터 노트북에서 아래 링크를 통해 다운받으실 수 있습니다. !curl -0 https://raw.githubusercontent.com/jakevdp/data-CDCbirths/master/births.csv --output ./births.csv 사전에 필요한 프레임워크를 임포트합니다. 그리고 필요한 데이터를 가져와서 데이터프레임 객체로 할당합니다. import numpy as np import pandas as pd births = pd.read_csv('./births.csv') 이러면 실습 준비 완료! 지금부터 낯선 데이터에 대해서 데이터먼징하는 작업을 차근차근 살펴보겠습니다. :D ..
-
Pandas 데이터 세트 결합하기: 병합과 조인데이터 분석/Pandas 2020. 8. 13. 07:16
Pandas 공식 User Guide 에서도 확인할 수 있다. - 선수지식: SQL JOIN Merge, join, concatenate and compare https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html Merge, join, concatenate and compare — pandas 1.1.0 documentation pandas has full-featured, high performance in-memory join operations idiomatically very similar to relational databases like SQL. These methods perform significantly better (..
-
Pandas 누락값 처리 - Handling Missing Values IN Python데이터 분석/Pandas 2020. 8. 8. 08:31
누락 값 처리하는 4가지 스킬 누락을 발견하고, 누락 규모 파악하고, 누락값을 채우거나 버리는 작업이 필요하다. Discovering missing values : isnull(), notnull() Counting missing values : isnull().sum() Filling in for missing values : fillna(), interpolate() Filtering out missing values : dropna() How to Identify and Drop Null Values | Handling Missing Values in Python 이 영상은 누락 값을 파악하고, 필터링하는 방법을 서술한 영상이다. 인도분이라 발음이 조금 힘들 수는 있지만 듣다보면 익숙해질 정도이고,..
-
Pandas 객체 소개 - Index데이터 분석/Pandas 2020. 6. 7. 14:25
Pandas Index 객체 Index 객체는 그 자체로 흥미로운 구조체이며 불변의 배열이나 정렬된 집합 (중복 허용) 으로 볼 수 있다. Index: 불변의 배열 Index 객체는 여러 면에서 배열처럼 동작한다. Index 객체는 NumPy배열에서 익숙한 속성이 많이 있다. 단, Index 객체는 일반적인 방법으로는 변경될 수 없는 불변의 값이다! Immutable 이 불변성 덕분에 예기치 않은 인덱스 변경으로 인한 부작용 없이 여러 DataFrame 과 배열 사이에서 인덱스를 더 안전하게 공유할 수 있다. Index: 정렬된 집합 Pandas 객체는 집합 연산의 여러 측면에 의존하는 데이터 세트 간의 조인과 같은 연산을 할 수 있게 하려고 고안되었다. 그래서 합집합, 교집합, 차집합을 비롯해 그 밖의..
-
Pandas 객체 소개 - DataFrame데이터 분석/Pandas 2020. 6. 7. 14:16
Series: 유연한 인덱스를 가지는 1차원 배열 DataFrame: 유연한 행 인덱스와 유연한 열 이름 (인덱스)을 가진 2차원 배열 Pandas DataFrame 객체 DataFrame 은 정렬된 Series 객체의 연속으로 볼 수 있다. 즉, 같은 인덱스를 공유하는 Series 객체의 조합이다. - 행 인덱스: 도시이름 공유 - 열 인덱스: (도시 단위) 인구수, (도시 단위) 면적 실제로 행과 열 모두 인덱스 객체이다. DataFrame: 특수한 딕셔너리 이렇게 행이름을 기준으로 Series 를 반환한다. DataFrame 객체 구성하기 단일 Series 객체에서 구성하기 DataFrame 은 Series 객체의 집합체로서 열 하나짜리 DataFrame 은 단일 Series 로부터 구성할 수 있다..
-
Pandas 객체 소개 - Series데이터 분석/Pandas 2020. 6. 7. 13:36
Pandas 튜토리얼 및 다큐멘테이션을 펴놓고 시작! http://pandas.pydata.org/ pandas - Python Data Analysis Library pandas pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language. Install pandas now! pandas.pydata.org Pandas 의 세 가지 기본 자료구조인 Series, DataFrame, Index 에 대해 알아보자. Pandas Series 객체 Pandas Series 는 인덱싱된 데이터의 1차원 배열..