파이썬(Python)&판다스(Pandas)&Polars
[polars] 셀 안의 문자열 또는 리스트 값 모두 보이게 출력(polars.Config.set_fmt_str_lengths, max_colwidth)
송채채
2023. 11. 21. 15:07
polas에서 데이터프레임을 출력하면 긴 문자열을 아래 사진처럼 끊긴다
- pandas에서는 max_colwidth을 쓰면 해결됐었음
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.option_context.html
pandas.option_context — pandas 2.1.3 documentation
next pandas.option_context.__call__
pandas.pydata.org
- 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)
반응형