Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Linux
- javascript
- PyQt
- PyQt5
- 맛집
- 리눅스
- ASP
- 다이어트
- 라즈베리파이
- MS-SQL
- sqlite
- Unity
- Excel
- tensorflow
- 함수
- swift
- PER
- GIT
- urllib
- 날짜
- flutter
- ubuntu
- pandas
- MySQL
- 유니티
- IOS
- node.js
- python
- mssql
- port
Archives
목록2024/07/15 (2)
아미(아름다운미소)
pandas 빈데이타프레임처리
if result.empty: result = pd.DataFrame(columns=['A', 'C'])
랭귀지/pandas
2024. 7. 15. 14:56
pandas to_numeric
여러컬럼import pandas as pddf = pd.DataFrame({ 'A': ['a', 'a', 'b', 'b', 'c', 'c','x'], 'B': ['x', 'y', 'x', 'y', 'x', 'y','y'], 'C': [10.5, '20', 30.2, 'aaa', '50.1', '60',None], 'D': [1.0, '2', 3.2, 'bbb', 5.1, '6',None]})numeric_cols = ['C', 'D']#방법1df = df.assign(**{col: pd.to_numeric(df[col], errors='coerce').fillna(0).astype(int) for col in numeric_cols})#방법2df[numeric_cols] = df[n..
랭귀지/pandas
2024. 7. 15. 11:43