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
- IOS
- urllib
- ubuntu
- port
- Linux
- 날짜
- javascript
- pandas
- 라즈베리파이
- MySQL
- swift
- 리눅스
- node.js
- PER
- ASP
- python
- GIT
- Unity
- PyQt
- 유니티
- Excel
- MS-SQL
- tensorflow
- mssql
- 다이어트
- flutter
- PyQt5
- 함수
- sqlite
- 맛집
Archives
아미(아름다운미소)
object 타입 컬럼을 모두 문자열(str)로 변환 본문
import pandas as pd
def convert_object_columns_to_str(df: pd.DataFrame) -> pd.DataFrame:
"""
Pandas DataFrame에서 object 타입 컬럼을 모두 문자열(str)로 변환합니다.
Parameters:
df (pd.DataFrame): 변환할 DataFrame
Returns:
pd.DataFrame: 문자열 컬럼이 str 타입으로 변환된 DataFrame
"""
df = df.copy()
for col in df.select_dtypes(include='object').columns:
df[col] = df[col].astype(str)
return df
import polars as pl
pandas_df = pd.read_csv("data.csv")
pandas_df = convert_object_columns_to_str(pandas_df)
lazy_df = pl.from_pandas(pandas_df).lazy()
Comments
