[Tutor] pandas.to_clipboard() copies nothing

Peter Otten __peter__ at web.de
Sat Jun 6 05:25:19 EDT 2020


Jim wrote:

> Mint18.3, python3.6, pandas 0.24.1
> 
> 
> et_file = '/home/jfb/Downloads/PortfolioDownload.csv'
> df = pd.read_csv(et_file, header=6, usecols=[0, 7], skipfooter=6,
> engine='python')
> df.to_clipboard(sep=',')
> print(df)
> 
> Manual notes the following. I'm not using PyQt4, but xclip is installed.
> 
> Notes: Requirements for your platform.
> 
>      Linux : xclip, or xsel (with PyQt4 modules)
>      Windows : none
>      OS X : none
> 
> The print command prints what I expect to see.
> 
> I don't use pandas that much so maybe I am missing something.

The pandas side seems OK; maybe you are looking at the wrong selection?
I have a slightly different setup, and the following works for me:

$ python3
Python 3.4.3 (default, Nov 12 2018, 22:25:49) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> df = pandas.DataFrame([[1,2], [3, 4]], columns=["Ham", "Spam"])
>>> df.to_clipboard(sep=", ")
>>> 
$ xclip -o -selection clipboard
   Ham  Spam
0    1     2
1    3     4$ 




More information about the Tutor mailing list