python+numpy pandas 3편
TRANSCRIPT
![Page 1: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/1.jpg)
1
Moon Yong Joon
Python numpy,pandas기초 -3 편
![Page 2: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/2.jpg)
2
6. Pandas 모듈 기초 7. Pandas Series/ DataFrame 기초
8.Pandas series/dataframe 공통메소드 9. Pandas index class
10.Pandas groupby 처리 11. Pandas panel(3 차원 )
목차
![Page 3: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/3.jpg)
3
6. Pandas 모듈 기초
![Page 4: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/4.jpg)
4
Pandas 구조
![Page 5: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/5.jpg)
5
PANDAS 데이터 타입 구조
![Page 6: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/6.jpg)
6
1 차원의 데이터를 관리하는 컨테이너이면 dict 타입처럼 index 와 value 가 항상 연계되어 처리
Series 구조 : 1 차원
index
0
1
2
data: 실제 데이터 값 index : 데이터를 접근할 정보 index.name 으로 index 도 name 을 지정할 수 있음 dtypes : 데이터들의 타입 name : Series 인스턴스의 이름
values
dtypes
![Page 7: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/7.jpg)
7
1 차원의 데이터를 관리하는 컨터이너이며 index 등을 별도로 정의할 수 있음
Series 구조 생성
![Page 8: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/8.jpg)
8
Series 인스턴스들이 DataFrame 의 칼럼으로 들어가는 구조 columns 는 series 명이 되어야 하고 index 는 series 의 index 로 처리
DataFrame 구조 : 2 차원
Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
index
012
values
dtype
name
index012
values
dtype
name
index
012
values
dtype
name
Series 에서 DataFram
e 전환
![Page 9: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/9.jpg)
9
n*m 행렬구조를 가지는 데이터 구조이고 index 와 column 이 별도의 명을 가지고 , column 별로 다른 데이터 타입을 가질 수 있음
DataFrame 생성
Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
![Page 10: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/10.jpg)
10
3 차원의 데이터를 관리하는 컨테이너Panel 구조 : 3 차원
index
item0
item1
dataIndex( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
DataFrame
Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
data = {'Item1' : pd.DataFrame(np.random.randn(3, 3)), 'Item2' : pd.DataFrame(np.random.randn(3, 3))}pd.Panel(data)
![Page 11: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/11.jpg)
11
INDEX/SLICE 지원
![Page 12: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/12.jpg)
12
[ ] 연사자 내의 숫자는 마지막을 포함하지 않지만 문자일 경우 마지막 값도 처리
슬라이싱 처리시 숫자와 문자
[0,0] [0,1] [0,2]Row : 행
Column: 열0
0 1 2
[0,0] [0,1] [0,2]
Column: 열0
a b c
숫자로 조회 문자로 조회
![Page 13: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/13.jpg)
13
[ ] 연산자로 원소값 (scalar) 및 일차원 (Series) 조회
원소값 , 일차원
[0,0]Row : 행
Column: 열[0,0] [0,1] [0,2]
Row : 행
Column: 열0
0 1 2
![Page 14: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/14.jpg)
14
[ ] 조회로 2 차원과 3 차원 조회 2 차원 /3 차원
[0,0] [0,1] [0,2]
[1,0] [1,1] [1,2]
[2,0] [2,1] [2,2]
Row : 행
Column: 열0
1
2
0 1 2
![Page 15: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/15.jpg)
15
INDEX 구조
![Page 16: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/16.jpg)
16
labels, names 으로 분리해서 접근할 수 있는 정보를 관리
Index 에 대한 객체화
Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
labels
names
Index 에 대한 위치관리
Levels 에 대한 명
labels
names
Column 에 대한 위치관리
Levels 에 대한 명
Index( 행 ) Column( 열 )
![Page 17: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/17.jpg)
17
Levels, labels, names 으로 분리해서 접근할 수 있는 정보를 관리
multiIndex 에 대한 객체화
Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
levels
labels
names
Index 에 대한 이름관리
Index 에 대한 위치관리
Levels 에 대한 명levels
labels
names
Column 에 대한 이름관리
Column 에 대한 위치관리
Levels 에 대한 명
Index( 행 ) Column( 열 )
row1
row2
row3
col1 col2 col3
![Page 18: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/18.jpg)
18
Pandas Series class
![Page 19: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/19.jpg)
19
SERIES 구조
![Page 20: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/20.jpg)
20
1 차원의 데이터를 관리하는 컨테이너Series 구조
pandas.Series(data,index,dtypes,name,copy)
![Page 21: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/21.jpg)
21
CLASS 생성
![Page 22: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/22.jpg)
22
List 를 받아서 Series 인스턴스를 생성Series 생성 : list-like
![Page 23: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/23.jpg)
23
dict 를 받아서 키는 index, 값은 values 로 저장되는 Series 인스턴스를 생성
Series 생성 : dict-like
![Page 24: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/24.jpg)
24
Series 는 value 값을 ndarray 와 index 를 In-dex 타입으로 구성
Series 내부 data type
![Page 25: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/25.jpg)
25
INDEX 대체하기
![Page 26: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/26.jpg)
26
Index 에도 name 속성이 존재해서 index 내부의 name 부여
Series 생성 :index 에 name 부여
![Page 27: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/27.jpg)
27
SERIES INDEX/SLICE 검색
![Page 28: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/28.jpg)
28
Index 가 없을 경우 RangeIndex, 숫자로 in-dex 부여하면 Int64Index, 문자는 Index 타입으로
Series 조회 : index
Index 가 숫자나 문자로 검색이 가능함
![Page 29: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/29.jpg)
29
숫자는 RangeIndex, 문자는 Index 타입으로 관리하여 index 값으로 슬라이싱도 조회
Series 조회 : slice
문자로 slice 할때는 해당표시하는 것까지 포함되어 처리됨
![Page 30: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/30.jpg)
30
FANCY 검색
![Page 31: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/31.jpg)
31
논리식으로 처리하면 True/False 원소로 리스트가 생성되이 이 중에 True 인 것만 검색
Series 조회 : 논리식
![Page 32: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/32.jpg)
32
Fancy 접근처럼 [ ] 내부에 리스트로 index 정보를 주고 검색이 가능
Series 조회 :fancy 방법
![Page 33: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/33.jpg)
33
Pandas DataFrame class
![Page 34: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/34.jpg)
34
DATAFRAME CLASS 구조
![Page 35: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/35.jpg)
35
n*m 행렬구조를 가지는 데이터 구조 생성DataFrame 생성
class DataFrame(pandas.core.generic.NDFrame)
| 2 차원 행렬 | Parameters | ---------- | data : numpy.ndarray ,dict, or DataFrame | dict can contain Series, arrays, constants, or list-like objects | index : Index or array-like | 행에 대한 정보 기본은 np.arange(n), 명칭도 부여 가능 | columns : Index or array-like 행에 대한 정보 기본은 np.arange(n), 명칭도 부여 가능 | dtype : dtype, default None | Data type to force, otherwise infer | copy : boolean, default False | Copy data from inputs. Only affects DataFrame / 2d ndarray input
![Page 36: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/36.jpg)
36
Series 로 DataFrame 를 생성하고 하나의 칼럼을 조회해 보면 Series 타입으로 조회 되고 DataFrame의 values 는 ndarray 으로 2 차원으로 관리
DataFrame 내부 data type
![Page 37: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/37.jpg)
37
DataFrame 는 value 값을 ndarray 와 index를 Index 타입으로 구성
DataFrame 내부 data type
![Page 38: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/38.jpg)
38
CLASS 생성
![Page 39: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/39.jpg)
39
DataFrame 은 기본적으로 column 단위로 데이터를 관리함
DataFrame 생성 : 1 column
행
열col1
row1
row2
row3
![Page 40: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/40.jpg)
40
column 단위로 리스트를 만들어서 zip 을 이용해서 순서쌍을 만들고 데이터를 생성
DataFrame 생성 : list/tuple
![Page 41: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/41.jpg)
41
column 단위로 리스트를 만들어서 dict 에 대입해서 데이터를 생성하면 key 가 columns 명으로 들어감
DataFrame 생성 : dict
![Page 42: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/42.jpg)
42
DataFrame 정의시 columns 정의한 순서대로 저장됨
DataFrame 칼럼 추가 : 순서
![Page 43: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/43.jpg)
43
SERIES 를 이용해서 생성
![Page 44: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/44.jpg)
44
series 로 dataframe 을 생성하면 series index 는 행(index) 으로 가고 series name 은 열 (column) 로 표시
Dataframe : Series 1 개로 생성
![Page 45: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/45.jpg)
45
series 를 list 로 dataframe 을 생성하면 se-ries index 는 칼럼으로 가고 series name 은 index 로 표시
Dataframe : list(Series)
List 로 생성시 행과 열이 바뀌므로 주의해야 함
![Page 46: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/46.jpg)
46
series 를 dict 으로 dataframe 을 생성하면 series index 는 index 으로 가고 series name은 columns 로 표시
Dataframe : dict(Series) 1
![Page 47: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/47.jpg)
47
series 를 dict 으로 dataframe 을 생성하면 series index 는 index 으로 가고 series name은 columns 로 표시
Dataframe : dict(Series) 2
![Page 48: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/48.jpg)
48
series 를 dict comprehension 을 이용해서 dataframe 을 생성하면 series index 는 index으로 가고 series name 은 columns 로 표시
Dataframe : dict comprehension
![Page 49: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/49.jpg)
49
INDEX/COLUMNS 대체하기
![Page 50: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/50.jpg)
50
Index 의 원소는 변경이 불가하지만 전체를 대체할 수 있음
DataFrame index 대체
![Page 51: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/51.jpg)
51
DataFrame 은 기존에 행에 이름을 부여 (index 속성 )
DataFrame : index 이름 부여
행
열 col1
row1
row2
row3
col2
![Page 52: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/52.jpg)
52
DataFrame 은 기본적으로 column 명을 추가를 할 수 있지만 실제는 칼럼명이 대체되는 것
DataFrame : column 명 변경
행
열 col1
row1
row2
row3
![Page 53: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/53.jpg)
53
DATAFRAME 칼럼 검색
![Page 54: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/54.jpg)
54
DataFrame. 칼럼명으로 조회하면 칼럼단위로 조회가 가능
DataFrame 칼럼명으로 조회
![Page 55: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/55.jpg)
55
DataFrame 은 기존에 행에 이름을 부여 (index 속성 )
DataFrame 행 이름 부여
행
열 col1
row1
row2
row3
col2
![Page 56: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/56.jpg)
56
객체의 속성에 접근하는 것처럼 칼럼이름을 속성으로 표시해서 접근해 데이터 검색
DataFrame 접근 : 속성형식 조회
![Page 57: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/57.jpg)
57
DataFrame 은 단일 열을 인덱스 방식 ([ ])
DataFrame 검색 : column
행
열 col1
row1
row2
row3
col2
![Page 58: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/58.jpg)
58
DataFrame 은 멀티 열은 슬라이스 방식 ([ [ , ] ])을 사용하지만 칼럼명을 리스트로 작성해서 검색
DataFrame 검색 : multi column
행
열 col1
row1
row2
row3
col2
![Page 59: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/59.jpg)
59
DATAFRAME 논리식 접근
![Page 60: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/60.jpg)
60
DataFrame 내의 논리식을 표현하면 True 일 경우 출력됨
DataFrame 조회 : 논리식
![Page 61: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/61.jpg)
61
DATAFRAME FANCY 검색
![Page 62: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/62.jpg)
62
[[“ 칼럼 위치” ]] 로 조회하면 칼럼 기준으로 접근해서 데이터 검색
DataFrame 접근 : 칼럼위치
![Page 63: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/63.jpg)
63
여러 개의 칼럼 ([[ 칼럼위치 ]]) 을 기준으로 접근해서 데이터 검색
DataFrame 접근 : 여러개 칼럼위치
![Page 64: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/64.jpg)
64
Pandas 함수 및 메소드 처리
![Page 65: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/65.jpg)
65
동일 규칙 함수나 메소드 지원
![Page 66: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/66.jpg)
66
Pandas 도 메소드가 동일 이름으로 class 마다 정의되어있고 처리 방식도 유사
동일 메소드 지원
Series class
메소드DataFrame class
메소드
![Page 67: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/67.jpg)
67
Series 이 index 범위가 벗어나면 KeyError 발생
Series 조회 : No Index
![Page 68: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/68.jpg)
68
Series 이 index 범위가 벗어나도 KeyError 발생하지 않으려면 get() 메소드를 사용해서 in-dex 범위를 초과할 경우 사용
Series 조회 : get() 메소드
![Page 69: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/69.jpg)
69
DataFrame 이 index 범위가 벗어나면 KeyEr-ror 발생
DataFrame 조회 : No Index
![Page 70: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/70.jpg)
70
DataFrame 이 index 범위가 벗어나도 Key-Error 발생하지 않으려면 get() 메소드를 사용해서 index 범위를 초과할 경우 사용
DataFrame 조회 : get() 메소드
![Page 71: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/71.jpg)
71
데이터 복사
![Page 72: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/72.jpg)
72
Serise 와 DataFrame 의 색인은 view 를 보여주므로 별도의 복사본이 필요한 경우 반드시 copy해서 사용
복사본을 만들고 갱신처리
![Page 73: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/73.jpg)
73
copy 메소드를 이용해서 생성하면 다른 인스턴스가 생성되지만 값을 비교 (==) 와 인스턴스비교 (is) 는 다른 결과가 나옴
Series 카피 후 생성 : copy
![Page 74: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/74.jpg)
74
copy 메소드를 이용해서 생성하면 다른 인스턴스가 생성되지만 값을 비교 (==) 와 인스턴스비교 (is) 는 다른 결과가 나옴
DataFrame 카피 후 생성 : copy
![Page 75: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/75.jpg)
75
GROUPBY 처리
![Page 76: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/76.jpg)
76
하나의 칼럼을 기준으로 group 화해서 칼럼들에 대한 연산 처리
Groupby
letter one two0 a 1 21 a 1 22 b 1 23 b 1 24 c 1 2
one two
lettera 2 4
b 2 4
c 1 2
letter one two0 a 1 21 a 1 22 b 1 23 b 1 24 c 1 2
twoletter onea 1 4b 1 4c 1 2
![Page 77: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/77.jpg)
77
APPLY 처리
![Page 78: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/78.jpg)
78
Apply 메소드는 내부 함수를 모든 원소에 대해 계산을 처리함
Dataframe 모든 원소에 적용
Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
df.apply(func)
Apply 메소드
func(df 원소값 ) 을 넣어 전체 값을 전환Index( 행 )
Column( 열 )
col1 col2 col3
row1
row2
row3
![Page 79: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/79.jpg)
79
Pandas Matplotlib 처리
![Page 80: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/80.jpg)
80
PLOT 함수 사용하기
![Page 81: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/81.jpg)
81
Series 로 matplotlib 그래프 그리기Series
![Page 82: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/82.jpg)
82
DataFrame 로 matplotlib 그래프 그리기DataFrame
![Page 83: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/83.jpg)
83
7. Pandas Series/Dataframe 기초
![Page 84: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/84.jpg)
84
SERIES 변수
![Page 85: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/85.jpg)
85
Index 는 index, 원소는 values 에 보관됨Series 구조 속성 1
변수 설명name Series 인스턴스에 대한 이름shape DataFrame 의 행렬 형태를 표시dtypes 행과 열에 대한 데이터 타입을 표시ndim 차원에 대한 정보 표시
strides 데이터를 구성하는 총 갯수index 생성된 행에 대한 index 표시values 실제 data 를 Numpy 로 변환
![Page 86: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/86.jpg)
86
원소의 개수는 타입 등 추가 정보를 보관Series 구조 속성 2
변수 설명size 원소들의 갯수
ftypes Return the ftypes (indication of sparse/dense and dtype) in this object.
axes 행과 열에 대한 축을 접근 표시empty 내부가 없으면 True 원소가 있으면 False
base 기본 데이터의 메모리를 공유하는 경우에는 기본 객체를 반환
![Page 87: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/87.jpg)
87
Axes( 축 ) 은 Index 클래스에 대한 정보를 가지고 있고 , index(0) 에 대한 labels 구성에 대한 축을 관리
attribute : axes
![Page 88: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/88.jpg)
88
Series 변환 속성 3
변수 설명
T 행과 열을 변환
![Page 89: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/89.jpg)
89
Series 내부구조 검색
![Page 90: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/90.jpg)
90
SERIES 내부 VIEW 제공
![Page 91: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/91.jpg)
91
blocks, ix, iat,at,iloc,loc 등 다양한 접근 방안을 제공
Series 내부 view 제공
![Page 92: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/92.jpg)
92
SERIES 내부 VIEW : BLOCK
![Page 93: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/93.jpg)
93
Series 인스턴스를 dict 타입으로 변환처리Series 구조 변환 : blocks
dtypes
index
0
1
2
val-ues
Key(dtype)
Value(Series)
Series
Series 를dict 로전환
![Page 94: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/94.jpg)
94
SERIES 내부 VIEW : IX
![Page 95: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/95.jpg)
95
주요 Series 인스턴스의 값을 접근하기 위해 ix 객체를 제공하고 label, index 로 접근이 가능
Series 접근 : ix
![Page 96: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/96.jpg)
96
개별 원소별로 접근해서 처리Series 접근 : ix 원소별 접근
![Page 97: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/97.jpg)
97
Slicing 접근시 index 가 문자일 경우는 문자가 해당하는 위치까지 포함
Series 접근 : ix slicing 접근
![Page 98: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/98.jpg)
98
SERIES 내부 VIEW : 기타
![Page 99: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/99.jpg)
99
주요 Series 인스턴스의 값을 접근하기 위해 at은 레이블 ,iat 은 인덱스로 처리해서 값을 검색
Series 접근 : at/iat
![Page 100: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/100.jpg)
100
주요 Series 인스턴스의 값을 접근하기 위해 loc는 값과 슬라이싱 처리를 포함해서 검색 , 칼럼명으로 조회시는 마지막도 검색됨
Series 접근 : loc/iloc
![Page 101: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/101.jpg)
101
Dataframe 변수
![Page 102: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/102.jpg)
102
DATAFRAME 기본 속성
![Page 103: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/103.jpg)
103
이름과 생일을 한쌍을 만들어서 dataframe 으로 생성
DataFrame 생성
Index( 행 )
Column( 열 )
col1
col2
row1
row2
row3
![Page 104: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/104.jpg)
104
Index, columns, shape 에 대한 정보 조회attribute : Index, columns, shape
변수 설명shape DataFrame 의 행렬 형태를 표시index 행에 대한 접근 표시
columns 칼럼에 대한 접근 표시
![Page 105: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/105.jpg)
105
dtypes, at(indexing/slicing), ndim 에 대한 속성 값들을 확인
attribute : dtypes, ndim
변수 설명ndim 차원에 대한 정보 표시
dtypes 행과 열에 대한 데이터 타입을 표시
![Page 106: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/106.jpg)
106
empty, ftypes 에 대한 속성 값들을 확인attribute : empty, ftypes
변수 설명ftypes
Return the ftypes (indication of sparse/dense and dtype) in this ob-ject.
empty DataFrame 내부가 없으면 True 원소가 있으면 False
![Page 107: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/107.jpg)
107
size, values, T 에 대한 속성 값들을 확인attribute : size, values, T
변수 설명size 원소들의 갯수
values Numpy 로 변환T 행과 열을 변환
![Page 108: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/108.jpg)
108
Axes( 축 ) 은 Index 클래스에 대한 정보를 가지고 있고 , index(0)/ columns(1) 에 대한 labels구성에 대한 축을 관리
attribute : axes
![Page 109: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/109.jpg)
109
DataFrame 내부구조 검색
![Page 110: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/110.jpg)
110
DATAFRAME: BLOCKS
![Page 111: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/111.jpg)
111
DataFrame 의 blocks 속성에 가지고 있는 정보를 검색
DataFrame.blocks
![Page 112: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/112.jpg)
112
DataFrame 의 blocks 속성에 정의된 타입을 기준으로 칼럼 정보를 검색
DataFrame.blocks 내부 조회
![Page 113: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/113.jpg)
113
DATAFRAME: IX
![Page 114: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/114.jpg)
114
ix 로 내부 값을 조회 DataFrame.ix
![Page 115: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/115.jpg)
115
DataFrame 의 ix 는 숫자로 내부의 series 와 값을 조회
DataFrame.ix 조회
![Page 116: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/116.jpg)
116
DataFrame 은 ix 속성을 이용해서 행과 열을 동시에 검색 ([ 행 ( 슬라이싱 : ), 칼럼 ( 명 ) ])
DataFrame 행과열 검색 1
행
열 col1
row1
row2
row3
col2
![Page 117: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/117.jpg)
117
DataFrame 은 ix 속성을 이용해서 행과 복수의 열을 동시에 검색 ([ 행 ( 슬라이싱 : ), [ 칼럼명 , 칼럼명 ])
DataFrame 행과열 검색 2
행
열 col1
row1
row2
row3
col2
![Page 118: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/118.jpg)
118
슬라이싱할 경우는 뒤에 행이 포함되지 않지만 내부 속성으로 접근시는 뒤에 행도 포함해서 표시
row 접근시 슬라이싱 계산차이
![Page 119: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/119.jpg)
119
DataFrame 의 ix 는 숫자로 내부의 series 와 값을 갱신
DataFrame.ix 갱신
![Page 120: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/120.jpg)
120
DATAFRAME: IAT/AT
![Page 121: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/121.jpg)
121
iat 로 내부 값을 조회 DataFrame.iat
![Page 122: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/122.jpg)
122
at 로 lable 로 내부 값을 조회 DataFrame.at
![Page 123: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/123.jpg)
123
DATAFRAME: ILOC/LOC
![Page 124: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/124.jpg)
124
loc 로 내부 값을 조회 DataFrame.loc
![Page 125: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/125.jpg)
125
DataFrame 은 단일 행을 인덱스 방식 ([ ])
DataFrame 단일 행 검색
행
열 col1
row1
row2
row3
col2
![Page 126: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/126.jpg)
126
DataFrame 은 멀티행을 슬라이싱 방식 ([ : ]) 을 사용하지만 이름으로 검색시에는 해당 이름까지 포함해서 처리
DataFrame 멀티 행 검색
행
열 col1
row1
row2
row3
col2
![Page 127: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/127.jpg)
127
iloc 로 숫자로 내부 (series, 값 ) 를 조회 DataFrame.iloc
![Page 128: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/128.jpg)
128
8. Pandas series/dataframe 공통 메소드
![Page 129: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/129.jpg)
129
데이터 head/tail 확인
![Page 130: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/130.jpg)
130
SERIES
![Page 131: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/131.jpg)
131
Head/tail 조회 default 가 5 건이며 , n= 숫자를 인자로 전달해서 더 많은 건을 조회할 수 있음
Series head/tail 조회
![Page 132: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/132.jpg)
132
DATAFRAME
![Page 133: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/133.jpg)
133
DataFrame 은 head() 메소드를 이용해서 de-fault=5 까지 검색
DataFrame head 검색
![Page 134: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/134.jpg)
134
DataFrame 은 tail() 메소드를 이용해서 de-fault=5 까지 검색
DataFrame tail 검색
![Page 135: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/135.jpg)
135
데이터 요소 확인
![Page 136: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/136.jpg)
136
SERIES
![Page 137: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/137.jpg)
137
Series 생성시 NaN 값이 들어가면 isnull/notnull 메소드나 함수로 확인
Isnull/notnull
![Page 138: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/138.jpg)
138
Series count 메소드를 이용해서 null 이 아닌 갯수를 처리
Series 원소의 갯수 :count
![Page 139: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/139.jpg)
139
Series value_counts 메소드를 사용해서 원소들이 구성을 확인
Series 원소의 갯수 : value_counts
![Page 140: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/140.jpg)
140
key 는 index 이고 values 는 값을 를 확인iteritems 메소드는 index,value 가 쌍으로 구성
Iterable 처리 : iteritems
![Page 141: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/141.jpg)
141
주로 series 타입이 string 일 경우 series.str.문자열메소드를 이용해서 처리하도록 구현
Series.str
![Page 142: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/142.jpg)
142
DATAFRAME
![Page 143: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/143.jpg)
143
count 메소드를 이용해서 null 이 아닌 갯수를 처리count
![Page 144: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/144.jpg)
144
Dataframe 을 iterable 하게 처리하면 칼럼명과 칼럼값들의 쌍 (column name, Series) 으로 조회
Iterable 처리 : iteritems
![Page 145: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/145.jpg)
145
Dataframe 을 iterable 하게 처리하면 행명과 행값들의 쌍 (index, Series) 으로 조회
Iterable 처리 : iterrows
![Page 146: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/146.jpg)
146
Dataframe 을 iterable 하게 처리하면 행명과 행값들의 쌍 (index, Series) 으로 조회
Iterable 처리 : itertuples
![Page 147: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/147.jpg)
147
주로 dataframe 타입내의 칼럼 즉 series 가 string 일 경우 series.str. 문자열메소드를 이용해서 처리하도록 구현
DataFrame: Series.str
![Page 148: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/148.jpg)
148
데이터 요소 추가 / 갱신 메소드
![Page 149: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/149.jpg)
149
SERIES
![Page 150: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/150.jpg)
150
1 원에 대한 index 하나를 가지고 원소에 대해 조회 및 값 변경
get_value/set_value
![Page 151: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/151.jpg)
151
Series 들을 연결하기 위해 append 메소드를 사용하고 , index 정보가 순서적으로 붙이고 싶으면 index 를 변경이 필요
Series 들을 연결 :append
![Page 152: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/152.jpg)
152
DATAFRAME
![Page 153: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/153.jpg)
153
다차원에 대한 index,column 을 지정해서 원소에 대해 조회 및 값 변경
get_value/set_value
![Page 154: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/154.jpg)
154
행 / 열기준으로 두 객체를 연결Concat: 행과 열기준으로 연결 1
![Page 155: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/155.jpg)
155
행 / 열기준으로 두 객체를 연결Concat: 행과 열기준으로 연결 2
![Page 156: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/156.jpg)
156
행의 값이 일치한 부분이 없을에는 empty 처리 DataFrame : merge 병합
![Page 157: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/157.jpg)
157
subject_id 에 값으로 일치하는 것만 처리DataFrame : merge Inner join
![Page 158: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/158.jpg)
158
열기준 (subject_id) 으로 모든 것을 표시DataFrame : merge Outer join
![Page 159: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/159.jpg)
159
데이터 타입 변환
![Page 160: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/160.jpg)
160
SERIES
![Page 161: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/161.jpg)
161
타입을 변경해서 다른 series 생성 astype : 타입 변환 후 생성
![Page 162: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/162.jpg)
162
DATAFRAME
![Page 163: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/163.jpg)
163
타입을 변경해서 다른 dataframe 생성 astype : 타입 변환 후 생성
![Page 164: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/164.jpg)
164
재색인하기
![Page 165: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/165.jpg)
165
SERIES
![Page 166: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/166.jpg)
166
인덱스를 지정한 대로 위치가 바뀌고 새로운 se-ries 를 생성함
Series sort : reindex()
![Page 167: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/167.jpg)
167
index 변수에 직접 index 값을 할당해서 변경Series reinex 후 index 변경
![Page 168: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/168.jpg)
168
Reindex 할 때 index 가 추가되면 NaN 값으로 채워지지만 ffill( 앞의 값 매칭 ) 이나 bfill( 뒤의 값 매칭 ) 을 method 에 지정하면 보간법 처리
Series reindex 시 값 넣기
![Page 169: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/169.jpg)
169
DATAFRAME
![Page 170: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/170.jpg)
170
DataFrame 내의 index 를 다시 index 해서 조정이 가능하며 index 가 추가시 fill_value 로 지정해서 값을 초기화
DataFrame: reindex
![Page 171: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/171.jpg)
171
DataFrame 내의 원소에 대한 index/columns를 지정해서 reindexing 처리
DataFrame : fill_value
![Page 172: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/172.jpg)
172
DataFrame 내의 원소에 대한 index 를 재지정해서 reindexing 처리시 값 처리는 method 인자에 ffill, bfill 를 넣어 앞이나 뒷의 값을 기준으로 넣음
DataFrame :method
![Page 173: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/173.jpg)
173
sorting
![Page 174: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/174.jpg)
174
SERIES
![Page 175: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/175.jpg)
175
값을 기준으로 내부 series 를 변경함Series sort : sort_values()
![Page 176: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/176.jpg)
176
DATAFRAME
![Page 177: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/177.jpg)
177
인덱스 (axis=0 은 행 , axis=1 은 열 ) 를 기준으로 내부 DataFrame 를 변경함
DataFrame sort : sort_index
![Page 178: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/178.jpg)
178
값을 기준으로 내부 DataFrame 를 변경함DataFrame sort : sort_values()
![Page 179: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/179.jpg)
179
DataFrame 내의 원소에 대한 sorting 하고 in-place 로 세팅해서 내부 변경처리
DataFrame sort_value
![Page 180: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/180.jpg)
180
값 변경
![Page 181: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/181.jpg)
181
SERIES
![Page 182: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/182.jpg)
182
Pop 메소드를 이용해서 칼럼을 꺼낸 후 삭제하기칼럼 삭제 : pop
![Page 183: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/183.jpg)
183
Replace 메소드는 값 전체를 바꾸므로 특정부분을 추출하여 적용할 경우에만 특정 값이 변경
Series 특정 원소 변경 : replace()
![Page 184: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/184.jpg)
184
DATAFRAME
![Page 185: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/185.jpg)
185
Insert 메소드를 이용해서 새로운 칼럼을 삽입칼럼 삽입 : insert
![Page 186: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/186.jpg)
186
Pop 메소드를 이용해서 칼럼을 꺼낸 후 삭제하기칼럼 삭제 : pop
![Page 187: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/187.jpg)
187
DataFrame. 칼럼명 또는 [‘ 칼럼명’ ] 으로 조회하면 칼럼단위로 갱신
DataFrame 칼럼 갱신다른 값으로 변경 동일 값으로 변경
![Page 188: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/188.jpg)
188
DataFrame[ 열 ] 로 갱신시 기존에 없는 칼럼이 있으면 칼럼 추가가 됨
DataFrame 갱신시 주의사항
![Page 189: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/189.jpg)
189
DataFrame 은 기존에 없는 column 에 값을 scala 로 할당시 행에 맞춰 Broadcasting 처리
DataFrame 칼럼 추가
행
열 col1
row1
row2
row3
col2
![Page 190: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/190.jpg)
190
DataFrame 은 기존에 없는 column 에 칼럼을 할당
DataFrame 칼럼 추가 : 칼럼복사
행
열 col1
row1
row2
row3
col2
![Page 191: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/191.jpg)
191
DataFrame 은 기존에 존재한 column 에 값을 추가할 경우 broadcasting 되어 칼럼이 변경
DataFrame 칼럼값 변경
행
열 col1
row1
row2
row3
col2
![Page 192: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/192.jpg)
192
칼럼별 swap 처리를 하려면 indexinf[ ] 처리하기 위해 리스트에 칼럼명을 사용해서 처리
DataFrame 접근 : swap 처리
![Page 193: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/193.jpg)
193
DataFrame 내의 원소를 검색한 후에 대치시킴Replace : 원소 한 개 변경
![Page 194: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/194.jpg)
194
DataFrame 내의 원소를 검색한 후에 대치시킴Replace : 원소 여러 개 변경
![Page 195: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/195.jpg)
195
삭제
![Page 196: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/196.jpg)
196
SERIES
![Page 197: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/197.jpg)
197
Drop 을 사용해서 요소를 제거함Series: drop
![Page 198: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/198.jpg)
198
del 로 요소를 하나씩 제거함Series: del
![Page 199: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/199.jpg)
199
DATAFRAME
![Page 200: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/200.jpg)
200
DataFrame 은 기존에 존재한 column 을 drop 메소드로 삭제
DataFrame 칼럼 삭제 : drop
![Page 201: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/201.jpg)
201
행과 열에 대한 값을 삭제 할 수 있다 . 열은 axis=1 도 추가해야 함 . 단 , 기존 값은 변경하지 않고 새로운 객체를 추가
DataFrame : drop
![Page 202: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/202.jpg)
202
문자열 칼럼인 name, axis =1( 칼럼 축 ) 을 삭제 Name 칼럼을 drop 삭제
![Page 203: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/203.jpg)
203
DataFrame 은 기존에 존재한 column 을 del 로 삭제
DataFrame 칼럼 삭제 : del
행
열 col1
row1
row2
row3
![Page 204: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/204.jpg)
204
산술연산 메소드
![Page 205: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/205.jpg)
205
SERIES
![Page 206: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/206.jpg)
206
Series 와 scalar 값과 계산시 전체를 vector 값으로 전환해서 계산하고 , vector 간 연산시는 index 가 매칭되지 않을 경우는 NaN 처리
Series 연산 : scalar/vector
![Page 207: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/207.jpg)
207
Series 인스턴스에 대한 산술연산 (+,-,*,/,//,%)
Series : +,-,*,/,//,%
![Page 208: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/208.jpg)
208
Series 인스턴스의 값들이 음수일 경우 절대값 (abs) 처리
Series : abs
![Page 209: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/209.jpg)
209
add/radd 메소드와 sub/rsub 메소드 사용Series 연산 : add/sub
![Page 210: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/210.jpg)
210
mul/rmul 메소드 와 mod/rmod 메소드 사용Series 연산 : mul/mod
![Page 211: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/211.jpg)
211
div/rdiv/floordiv/rfloordiv/truediv/rtruediv/divide 메소드 사용
Series 연산 : div
![Page 212: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/212.jpg)
212
Series 내의 최고 발생한 것을 확인하는 메소드Series : mode
![Page 213: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/213.jpg)
213
평균 (mean), 중앙값 (median), 표준편차 (std), 분산 (var) 에 대해 구하기
Series 합 , 평균 , 표준편차 , 분산
![Page 214: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/214.jpg)
214
평균 (mean), 표준편차 (std), 분산 (var) 등을 한번에 구하기 (describe)
Series 숫자 데이터 통합 조회
![Page 215: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/215.jpg)
215
문자들로 값을 구성할 경우 describe 는 count, unque, 빈도에 대한 결과를 series 타입으로 반환
Series 문자 데이터 통합 조회
![Page 216: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/216.jpg)
216
Series 인스턴스내의 동일한 숫자 원소가 몇 개인지를 확인 (nunique)
Series 동일한 숫자 원소 확인
![Page 217: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/217.jpg)
217
DATAFRAME
![Page 218: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/218.jpg)
218
DataFrame 간의 산술연산 계산산술연산자 이용
![Page 219: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/219.jpg)
219
add, sub, mul 산술연산에 대한 처리Dataframe : +, - , *
![Page 220: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/220.jpg)
220
truediv, floordiv, mod 산술연산에 대한 처리Dataframe : /,//, mod
![Page 221: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/221.jpg)
221
산술연산에 대한 처리Dataframe 간 우측산술연산
![Page 222: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/222.jpg)
222
산술연산에 대한 처리칼럼간 산술연산
![Page 223: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/223.jpg)
223
칼럼에 최대 빈도 값을 출력Mode 연산
![Page 224: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/224.jpg)
224
DataFrame 전체에 대한 전체 통계적 정보 조회 describe: 전체 통계정보 조회
![Page 225: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/225.jpg)
225
DataFrame 특정 칼럼에 대한 통계 정보 조회describe: 칼럼 통계정보 조회
![Page 226: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/226.jpg)
226
describe() 에 결과를 mean() 메소드로 확인 Describe 내 값을 메소드로 확인
![Page 227: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/227.jpg)
227
열에 대한 합 , 평균 , 표준편차 , 분산 처리합 , 평균 , 표준편차 , 분산 : 열
![Page 228: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/228.jpg)
228
행에 대한 합 , 평균 , 표준편차 , 분산 처리합 , 평균 , 표준편차 , 분산 : 행
![Page 229: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/229.jpg)
229
min/max 메소드
![Page 230: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/230.jpg)
230
SERIES
![Page 231: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/231.jpg)
231
Series 인스턴스 내의 원소들에 대한 min/max 구하거나 index 값을 구하기
min/max, idxmin/idxmax
![Page 232: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/232.jpg)
232
Series 인스턴스 내의 원소에 대한 min/max 를 찾고 최고값이나 최저값으로 변경하는 cummin/cummax 구하기
Series cummin/cummax
![Page 233: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/233.jpg)
233
비교나 논리 연산을 사용할 경우에도 Series 인스턴스 전체가 처리가 되므로 이를 축소해서 boolean 처리하기 위한 메소드
Boolean Reductions
![Page 234: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/234.jpg)
234
원소의 값이 논리식에 위한 전부 True 경우만 all()에서 True, any() 메소드는 하나의 True 만 존재해도 True 로 처리
any(), all() : 비교
![Page 235: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/235.jpg)
235
Bool 메소드는 하나의 원소의 값이 True/False 여부 체크 및 계산된 결과가 동등한지 처리하는 메소드
bool()/equals()
![Page 236: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/236.jpg)
236
DATAFRAME
![Page 237: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/237.jpg)
237
열에 대한 min/max 처리 min/max : 열
![Page 238: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/238.jpg)
238
행에 대한 min/max 처리 min/max : 행
![Page 239: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/239.jpg)
239
논리 연산에 대한 행 (axis=1), 열 (axis=0) 에 대한 처리
All
![Page 240: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/240.jpg)
240
행과 열의 논리 연산을 한 결과에 대해 축약형 논리값 표시
any
![Page 241: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/241.jpg)
241
계산된 결과가 동등한지 처리하는 메소드 equals()
![Page 242: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/242.jpg)
242
Dataframe apply
![Page 243: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/243.jpg)
243
APPLY 처리 특징
![Page 244: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/244.jpg)
244
Apply 메소드는 내부 함수를 모든 원소에 대해 계산을 처리함
Dataframe 모든 원소에 적용
![Page 245: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/245.jpg)
245
사용자 함수 정의 후 계산
![Page 246: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/246.jpg)
246
칼럼정보를 받아서 sum 과 count 등을 계산하는 함수 정의
사용자 함수 정의 확인
![Page 247: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/247.jpg)
247
Platoon, Casualties 칼럼에 대한 sum,count 의 산출을 groupby 기준으로 처리
사용자 함수로 산출
![Page 248: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/248.jpg)
248
APPLY 사용 계산
![Page 249: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/249.jpg)
249
Platoon 칼럼기준으로 Casulties 값을 가지고 합산 , 평균 , 표준편차 , 분산을 계산
Dataframe apply 적용
![Page 250: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/250.jpg)
250
Platoon 칼럼기준으로 Casulties 값을 가지고 합산 , 평균 , 표준편차 , 분산을 계산
Dataframe apply 적용
![Page 251: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/251.jpg)
251
APPLY/MAP 메소드
![Page 252: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/252.jpg)
252
문자열로 저장된 칼럼에 대해 소문자를 대문자로 전환Name 칼럼에 apply 메소드 적용
![Page 253: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/253.jpg)
253
문자열로 저장된 칼럼에 대해 소문자를 대문자로 전환Name 칼럼에 map 메소드 적용
![Page 254: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/254.jpg)
254
APPLYMAP 적용
![Page 255: Python+numpy pandas 3편](https://reader030.vdocuments.pub/reader030/viewer/2022012320/5871f2b51a28ab5c348b5dad/html5/thumbnails/255.jpg)
255
문자열 칼럼은 변경없이 숫자타입일 경우는 100 을 곱셈함
모든 칼럼에 대해 함수 적용