일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- postgresql
- autovacuum
- if
- 쉘
- pi
- 배열
- conda
- Unity
- DROP
- dataframe
- ubuntu
- null
- python
- SVN
- List
- C++
- Shader
- boost
- SSH
- awk
- c++11
- pandas
- FIND
- sqlite
- Eclipse
- mysql
- with
- expect
- sql
- ngui
- Today
- Total
목록프로그래밍/Python (64)
その先にあるもの…
list1 = ['A', 'B', 'C', 'D'] list2 = ['C', 'D', 'E', 'F'] [1, 2, 3, 4, 5, 6, 7, 8, 9] 합집합 union = list( set(list1) | set(list2) ) print( union ) [1, 2, 3, 4, 5, 6, 7, 8, 9] union = list( set().union(list1, list2) ) print( union ) [1, 2, 3, 4, 5, 6, 7, 8, 9] 교집합 intersection = list( set(list1) & set(list2) ) print( intersection ) [5] intersection = list( set(list1).intersection( list2 ) ) print( ..
x1 x2 x3 x4 0 1 11 111 1111 1 2 22 222 2222 2 3 33 333 3333 lt = [11, 22, 33] isin()함수는 특정값이 데이터 프레임에 있는지 확인 rt = df.isin( lt ) x1 x2 x3 x4 0 False True False False 1 False True False False 2 False True False False # isin함수의 출력의 마스크 rt = ~df.isin( lt ) x1 x2 x3 x4 0 True False True True 1 True False True True 2 True False True True #특정 행의 값을 확인할 때 rt = df.isin( lt ).all( 1 ) 0 False 1 False 2 Tr..
df = pd.DataFrame( [[1,2,3], [4,5,6], [7,8,9] ], index= ["row1", "row2", "row3"], columns=['col1', 'col2', 'col3'] ) col1 col2 col3 row1 1 2 3 row2 4 5 6 row3 7 8 9 Index(['row1', 'row2', 'row3'], dtype='object') // 'col3'을 새로운 인덱스로 선택한다. df1 = df.set_index( 'col3') col1 col2 col3 3 1 2 6 4 5 9 7 8 Int64Index([3, 6, 9], dtype='int64', name='col3') // 인덱스 reset // 기존의 인덱스는 새로운 열에 추가된다. // 인덱스가 정수..
변수 = tuple() 변수 = () //리스트로 넣기 변수 = tuple ( 리스트 ) //정수형 하나로 생성하기 변수 = ( 정수, )
출처: https://rfriend.tistory.com/450 [R, Python 분석과 프로그래밍의 친구 (by R Friend)] [Python pandas] DataFrame, Series의 행, 열 개수 세기 이번 포스팅에서는 Python pandas의 DataFrame, Series 의 행, 열의 개수를 세는 방법(how to count the number of rows and columns of pandas DataFrame and Series)을 소개하겠습니다. 간단한 것들이고, 이미.. rfriend.tistory.com 이번 포스팅에서는 Python pandas의 DataFrame, Series 의 행, 열의 개수를 세는 방법(how to count the number of rows a..
x1 x2 x3 x4 0 1 11 111 12 1 2 22 222 13 2 3 33 333 14 # 열(column) 삭제 del df['x1'] # axis = 1 세로 축 df = df.drop( 'x2', 1 ) df = df.drop( ['x3','x4'] , 1 ) # 행(row) 삭제 # 1번행 삭제 df = df.drop( 1, 0 ) # axis = 0 가로 축 # 0-,2번행 삭제 df = df.drop( [0,2], 0 )