티스토리 뷰
파이썬(Python)&판다스(Pandas)&Polars
[polars] 셀 안의 문자열 또는 리스트 값 모두 보이게 출력(polars.Config.set_fmt_str_lengths, max_colwidth)
송채채 2023. 11. 21. 15:07polas에서 데이터프레임을 출력하면 긴 문자열을 아래 사진처럼 끊긴다

- 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)
반응형
'파이썬(Python)&판다스(Pandas)&Polars' 카테고리의 다른 글
| [Python] 변수명을 for문으로 할당하기 - globals() (0) | 2023.11.21 |
|---|---|
| [polars] 특정 조건을 만족하는 데이터 조회(df.filter) (2) | 2023.11.21 |
| [polars] 데이터프레임의 특정 컬럼 또는 모든 컬럼의 데이터 타입 변경하기(cast) (1) | 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 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- pandas
- knowledgegraph
- docker
- PostgreSQL
- polars
- Encoding
- ChatGPT
- pdfmathtranslate
- AWS
- vscode
- 지식그래프
- Postgis
- python
- graphrag
- Claude
- LLM
- knowlegegraph
- MongoDB
- vectorsearch
- 키워드추출
- geospy
- hadoop
- PEFT
- rdflib
- Vue3
- rdffox
- vertorsearch
- TextRank
- SPARQL
- Kafka
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함
