Closed braaannigan closed 2 years ago
This would seem to be a feature request, rather than a bug?
While I really do like the truncation for long String / Categorical values, there's many use cases where I would like to actually see values longer than 15 characters. Is there any option to disable the truncation?
While I really do like the truncation for long String / Categorical values, there's many use cases where I would like to actually see values longer than 15 characters. Is there any option to disable the truncation?
I had the same issue; posting the answer here in case it's not immediately obvious. It looks like the environment variable POLARS_FMT_STR_LEN
is used to control the length of printed strings: https://github.com/pola-rs/polars/blob/master/py-polars/polars/_html.py#L96
Though you can obviously set this environment variable directly, it's probably a better idea to use the provided pl.Config. set_fmt_str_lengths
classmethod; so, to 'disable' truncation with respect to the maximum string length in some column:
max_len = df['my_string_col'].str.lengths().max()
pl.Config. set_fmt_str_lengths(max_len)
# equivalent to
os.environ['POLARS_FMT_STR_LEN'] = str(max_len)
What language are you using?
Python
Have you tried latest version of polars?
yes
What version of polars are you using?
0.13.40
What operating system are you using polars on?
MacOS
What language version are you using
python 3.10
Describe your bug.
When printing datafames in jupyter the full string values are printed. With long strings this makes each row very long and hard to read. In ipython and the base python terminal the behaviour is better - in these terminal only a certain number of characters are printed and the number can be reduced further (though not increased) with
pl.Config.set_tbl_width_chars
.What are the steps to reproduce the behavior?
Run the following in a notebook
What is the actual behavior?
Full string is printed in jupyter
What is the expected behavior?
What do you think polars should have done? Allowed us to limit the width of columns