일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- DROP
- 배열
- List
- mysql
- conda
- FIND
- Eclipse
- sqlite
- with
- c++11
- C++
- pandas
- ubuntu
- ngui
- python
- awk
- boost
- SSH
- expect
- dataframe
- pi
- SVN
- Unity
- if
- sql
- null
- 쉘
- Shader
- autovacuum
- Today
- Total
목록프로그래밍/Python (64)
その先にあるもの…
바꾸기 : replace( '바꿀문자열', '새문자열' )'123,456,789'.replace( ',' , '' )'123456789' maketrans( '바꿀문자', '변환문자' ) trans = str.maketrans( 'yo', 'hu' )'yahoo'.translate( trans )hahuu 분리: split( '기준 문자' )'123,456,789'.split( ',' )[ '123', '456', '789' ] 합체 : join( 문자 리스트 )','.join( ['123','456','789'] )'123,456,789' 대문자로 바꾸기 : upper() 소문자로 바꾸기 : lower() 공백 삭제" hello, world ".strip() "hello, world" 왼쪽 공백 삭제 ..
DataFrame.droplevel(self, level, axis=0) Return DataFrame with requested index / column level(s) removed. >>> df = pd.DataFrame([ ... [1, 2, 3, 4], ... [5, 6, 7, 8], ... [9, 10, 11, 12] ... ]).set_index([0, 1]).rename_axis(['a', 'b']) >>> df.columns = pd.MultiIndex.from_tuples([ ... ('c', 'e'), ('d', 'f') ... ], names=['level_1', 'level_2']) level_1 c d level_2 e f a b 1 2 3 4 5 6 7 8 9 10 11 12..
dataframe.merge( table1, table2 ) - inner join dataframe.merge( table1, table2, how='outer' ) - outer join1(키 값이 한쪽에만 있어도 데이터를 보여준다) dataframe.merge( table1, table2, how='left' ) dataframe.merge( table1, table2, how='right' ) dataframe.merge( table1, table2, on='column' ) //기준열의 이름이 두 테이블에서 다르다면 기준열을 명시한다. dataframe.merge( table1, table2, left_on='column', right_on='column' ) //데이터 열이 아닌 인덱스를 기준..
dataframe을 출력할 때 행이나 열이 많으면 ... 으로 생략되는데 출력을 조정하는 옵션이 있다. import pandas as pd pd.set_option('display.max_row', 500) pd.set_option('display.max_columns', 100) pandas.pydata.org/pandas-docs/version/0.23/generated/pandas.set_option.html
col1 col2 col3 col4 col5 0 1 2 3 4 5 1 1 2 3 4 5 2 1 2 4 5 6 3 7 8 9 10 11 4 12 13 14 15 16 del df['col1'] col2 col3 col4 col5 0 2 3 4 5 1 2 3 4 5 2 2 4 5 6 3 8 9 10 11 4 13 14 15 16 df.drop( ['col2', 'col3'], axis = 1('columns'), inplace=True ) col4 col5 0 4 5 1 4 5 2 5 6 3 10 11 4 15 16 df.drop( df.columns[ [1,3] ], axis = 'columns', inplace=True ) col1 col3 col5 0 1 3 5 1 1 3 5 2 1 4 6 3 7 9 ..
df = [[1 ,2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]] #중복된 행 확인 ( 동일한 데이터 체크 ) data.duplicated() 0 False 1 True 2 False 3 False 4 False dtype: bool #특정 열을 선택하여 중복된 행 확인 data.duplicated( ['col1', 'col2'] ) 0 False 1 True 2 True 3 False 4 False dtype: bool #중복된 행만 출력 data[data.duplicated()] col1 col2 col3 col4 col5 1 1 2 3 4 5 #중복된 행은 하나만 남기고 제거하기 data.d..