Skip to content

to_clipboard(excel=False) truncates strings to 50 characters #8305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
klonuo opened this issue Sep 17, 2014 · 9 comments
Closed

to_clipboard(excel=False) truncates strings to 50 characters #8305

klonuo opened this issue Sep 17, 2014 · 9 comments
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@klonuo
Copy link
Contributor

klonuo commented Sep 17, 2014

I hope this is not intended as I can't find the point in this behavior:

import pandas as pd
df = pd.DataFrame.from_dict({1: ''.join(['1234567890'] * 6)}, 'index')
df.to_clipboard(excel=False)

result copied to clipboard:

                                                   0
1  1234567890123456789012345678901234567890123456...

Another issue - trying to omit index:

df.to_clipboard(excel=False, index=False)

result copied to clipboard, just the same as previous (with index):

                                                   0
1  1234567890123456789012345678901234567890123456...

This doesn't happen if I leave excel parameter to default value.

@jreback
Copy link
Contributor

jreback commented Sep 18, 2014

can u show pd.show_versions()

@klonuo
Copy link
Contributor Author

klonuo commented Sep 18, 2014

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.8.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: x86
processor: x86 Family 6 Model 15 Stepping 11, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.1
nose: 1.3.4
Cython: 0.21
numpy: 1.9.0
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.2.0
sphinx: 1.2.3
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.7
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.4.0
openpyxl: 2.0.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.4.0
bs4: None
html5lib: 0.999
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: 2.5.4 (dt dec pq3 ext)

@jreback
Copy link
Contributor

jreback commented Sep 18, 2014

So I think this needs to have some options set inside to_clipboard. As the default display options are used (but since this is converting to text, I think you want to eliminate max values)

so maybe also need to set max_rows,max_cols and such.

This is a work-around, but will call this a bug too.

In [3]: df = pd.DataFrame.from_dict({1: ''.join(['1234567890'] * 6)}, 'index')

In [4]: with pd.option_context('display.max_colwidth',9999999):
   ...:         df.to_clipboard(excel=False)
   ...:     

                                                          0

1 123456789012345678901234567890123456789012345678901234567890

@jreback jreback added Bug Categorical Categorical Data Type Output-Formatting __repr__ of pandas objects, to_string and removed Categorical Categorical Data Type labels Sep 18, 2014
@jreback jreback modified the milestones: 0.15.0, 0.15.1 Sep 18, 2014
@jreback
Copy link
Contributor

jreback commented Sep 18, 2014

@klonuo if you'd like to do a pull-request would be great. tests are in pandas/io/tests/test_clipboard.py

should prob get a few test cases that fail on round-tripping (e.g. to_clipboard/from_clipboard) and test/fix for them

@klonuo
Copy link
Contributor Author

klonuo commented Sep 18, 2014

@jreback clipboard tests report fine, so I run whole test suite on current github version with there results:

  1. test_parsers.py crashes python at test_dialect (test_parsers.TestCParserHighMemory)
  2. Tests that that report error:
test_encode (pandas.io.tests.test_html.TestReadHtmlEncodingLxml)
test_boxplot (pandas.tests.test_graphics.TestDataFramePlots)
test_boxplot_empty_column (pandas.tests.test_graphics.TestDataFramePlots)
test_boxplot_vertical (pandas.tests.test_graphics.TestDataFramePlots)
test_to_excel (pandas.tests.test_panel.TestPanel)

with these traces: https://gist.github.com/cb45d6f160dc17b7d458
3. Doubtful skips:

  • pandas.io.tests.test_sql.*: various SKIP: Can't connect to postgresql server, although I successfully use pandas sql methods through sqlalchemy to my PostgreSQL server.
  • pandas.stats.tests.*: various SKIP: no statsmodels although I do have statsmodels

@jreback
Copy link
Contributor

jreback commented Sep 18, 2014

@klonuo not what I mean

I am showing you where to put NEW test for a pull request to fix this issue

@klonuo
Copy link
Contributor Author

klonuo commented Sep 18, 2014

Ah, OK. So you want me to make a test functions for above reported issues and then try to fix the issues?
If that's the idea, unfortunately I don't have any experience with writing tests. I can have a look and try tomorrow, but I don't promise results.

@jreback
Copy link
Contributor

jreback commented Sep 18, 2014

@klonuo best way to learn! just look at those tests, construct one which has this test case and fails, then make a fix.

Here are some resources!
https://github.com/pydata/pandas/wiki
https://github.com/pydata/pandas/wiki/Contributing
https://github.com/pydata/pandas/wiki/Using-Git

always welcome new contributions. lmk

@jreback
Copy link
Contributor

jreback commented Sep 23, 2014

closed by #8328

@jreback jreback closed this as completed Sep 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants