polas에서 데이터프레임을 출력하면 긴 문자열을 아래 사진처럼 끊긴다
- pandas에서는 max_colwidth을 쓰면 해결됐었음
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.option_context.html
- polars의 문법
pl.Config.set_fmt_str_lengths(200)
df = pl.DataFrame(
{
"txt": [
"Play it, Sam. Play 'As Time Goes By'.",
"This is the beginning of a beautiful friendship.",
]
}
)
df.with_columns(pl.col("txt").str.len_bytes().alias("len"))
with pl.Config(fmt_str_lengths=50):
print(df)
다른 polars의 Config는 공식홈페이지를 참고하면 됩니다.
- List 의 값을 전체 보려는 경우
pl.Config(fmt_table_cell_list_len=10)
반응형
'파이썬(Python)&판다스(Pandas)&Polars' 카테고리의 다른 글
[Python] 변수명을 for문으로 할당하기 - globals() (0) | 2023.11.21 |
---|---|
[polars] 특정 조건을 만족하는 데이터 조회(df.filter) (2) | 2023.11.21 |
[polars] 데이터프레임의 특정 컬럼 또는 모든 컬럼의 데이터 타입 변경하기(cast) (0) | 2023.11.21 |
[polars] write_csv로 UTF-8-SIG 처럼 저장하기(include_bom) (1) | 2023.11.21 |
[polars] with_columns(), map_elements(=apply) 컬럼 전처리 후 새로운 컬럼 만들기 (0) | 2023.11.17 |