ENHANCEMENT: to_clipboard(index=False)
Commonly in my work I am pasting a column of data into another program that I have no api for as an input. I cannot have the index index in the input. I will generally use the .to_clipboard() method paste in excel, then copy the column from excel. I would really like to avoid opening another program to solve this problem. Would there be a way to add a keyword argument such that the index is not copied to the clipboard?
import pandas as pd
df = pd.DataFrame({'a':[1,2,3,4]})
df.to_clipboard(index=False)
Expected Output
Values in clipboard
a
1
2
3
4
rather than
a
0 1
1 2
2 3
3 4
Output of pd.show_versions()
# INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.19.0
nose: 1.3.7
pip: 8.1.2
setuptools: 26.1.1.post20160901
Cython: None
numpy: 1.11.2
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: None
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: 1.1.0
tables: None
numexpr: 2.6.1
matplotlib: 1.5.2
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.43.0
pandas_datareader: None
**Comment From: pijucha**
Didn't you want rather this:
df = pd.DataFrame({'a':[1,2,3,4]})
df.to_clipboard(index=False)
It works for me in pandas 0.19. I believe `to_clipboard` usually accepts the same arguments as `to_csv`.
**Comment From: jreback**
yep this is a usage issue
**Comment From: WaylonWalker**
Thanks guys. The wording in the question was a mistake on my behalf. I never realized that to_clipboard() took index as a parameter. Thanks for the enlightenment this will save me time.
After taking a look through the source code I now see that it will take **kwargs from to_csv or to_string depending on if excel is True. That makes it much more sense, and gives me a whole new list of options when using to_clipboard()