@@ -2041,26 +2041,58 @@ def to_pickle(self, path, compression='infer',
2041
2041
protocol = protocol )
2042
2042
2043
2043
def to_clipboard (self , excel = True , sep = None , ** kwargs ):
2044
- """
2045
- Attempt to write text representation of object to the system clipboard
2044
+ r"""
2045
+ Copy object to the system clipboard.
2046
+
2047
+ Write a text representation of object to the system clipboard.
2046
2048
This can be pasted into Excel, for example.
2047
2049
2048
2050
Parameters
2049
2051
----------
2050
- excel : boolean, defaults to True
2051
- if True, use the provided separator, writing in a csv
2052
- format for allowing easy pasting into excel.
2053
- if False, write a string representation of the object
2054
- to the clipboard
2055
- sep : optional, defaults to tab
2056
- other keywords are passed to to_csv
2052
+ excel : bool, default True
2053
+ - True, use the provided separator, writing in a csv format for
2054
+ allowing easy pasting into excel.
2055
+ - False, write a string representation of the object to the
2056
+ clipboard.
2057
+
2058
+ sep : str, default ``'\t'``
2059
+ Field delimiter.
2060
+ **kwargs
2061
+ These parameters will be passed to DataFrame.to_csv.
2062
+
2063
+ See Also
2064
+ --------
2065
+ DataFrame.to_csv : Write a DataFrame to a comma-separated values
2066
+ (csv) file.
2067
+ read_clipboard : Read text from clipboard and pass to read_table.
2057
2068
2058
2069
Notes
2059
2070
-----
2060
- Requirements for your platform
2061
- - Linux: xclip, or xsel (with gtk or PyQt4 modules)
2062
- - Windows: none
2063
- - OS X: none
2071
+ Requirements for your platform.
2072
+
2073
+ - Linux : `xclip`, or `xsel` (with `gtk` or `PyQt4` modules)
2074
+ - Windows : none
2075
+ - OS X : none
2076
+
2077
+ Examples
2078
+ --------
2079
+ Copy the contents of a DataFrame to the clipboard.
2080
+
2081
+ >>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])
2082
+ >>> df.to_clipboard(sep=',')
2083
+ ... # Wrote the following to the system clipboard:
2084
+ ... # ,A,B,C
2085
+ ... # 0,1,2,3
2086
+ ... # 1,4,5,6
2087
+
2088
+ We can omit the the index by passing the keyword `index` and setting
2089
+ it to false.
2090
+
2091
+ >>> df.to_clipboard(sep=',', index=False)
2092
+ ... # Wrote the following to the system clipboard:
2093
+ ... # A,B,C
2094
+ ... # 1,2,3
2095
+ ... # 4,5,6
2064
2096
"""
2065
2097
from pandas .io import clipboards
2066
2098
clipboards .to_clipboard (self , excel = excel , sep = sep , ** kwargs )
0 commit comments