
아래 구조와 같이 col1, col2 중 먼저 나오는 데이터를 기준으로 새로운 컬럼을 만들어야하는 경우가 있다. 이때는 'combine_first'를 사용하면 만들 수 있다. import pandas as pd #둘 중 하나에 값이 있으면 합치기 df['new_col'] = df['col1'].combine_first(df['col2']) df.drop([['col1','col2]], axis=1, inplace=True) # 필요없는 컬럼은 삭제 참고 블로그 - https://wikidocs.net/153673 08-02. 다른 객체로 결측치 덮어쓰기 (combine_first) ####DataFrame.combine_first(other) ##개요 `combine_first` 메서드는 `other`의..
파이썬(Python)&판다스(Pandas)&Polars
2022. 10. 24. 17:43
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Claude
- deepseek
- python
- python'
- SPARQL
- vscode
- PostgreSQL
- pdfmathtranslate
- rdffox
- vertorsearch
- Vue3
- LLM
- writerow
- rdflib
- 지식그래프
- PEFT
- Encoding
- hadoop
- vervel
- pandas
- cursorai
- psycopg
- polars
- geospy
- ChatGPT
- 키워드추출
- vectorsearch
- MongoDB
- Postgis
- TextRank
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함