File tree 4 files changed +31
-7
lines changed
4 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,8 @@ API Changes
207
207
- ``Series.get `` with negative indexers now returns the same as ``[] `` (:issue: `4390 `)
208
208
- allow ``ix/loc `` for Series/DataFrame/Panel to set on any axis even when the single-key is not currently contained in
209
209
the index for that axis (:issue: `2578 `, :issue: `5226 `)
210
+ - Default export for ``to_clipboard `` is now csv with a sep of `\t ` for
211
+ compat (:issue: `3368 `)
210
212
- ``at `` now will enlarge the object inplace (and return the same) (:issue: `2578 `)
211
213
212
214
- ``HDFStore ``
Original file line number Diff line number Diff line change @@ -868,9 +868,15 @@ def load(self, path): # TODO remove in 0.14
868
868
warnings .warn ("load is deprecated, use pd.read_pickle" , FutureWarning )
869
869
return read_pickle (path )
870
870
871
- def to_clipboard (self ):
871
+ def to_clipboard (self , sep = None , ** kwargs ):
872
872
"""
873
873
Attempt to write text representation of object to the system clipboard
874
+ This can be pasted into Excel, for example.
875
+
876
+ Parameters
877
+ ----------
878
+ sep : optional, defaults to comma
879
+ other keywords are passed to to_csv
874
880
875
881
Notes
876
882
-----
@@ -880,7 +886,7 @@ def to_clipboard(self):
880
886
- OS X: none
881
887
"""
882
888
from pandas .io import clipboard
883
- clipboard .to_clipboard (self )
889
+ clipboard .to_clipboard (self , sep , ** kwargs )
884
890
885
891
#----------------------------------------------------------------------
886
892
# Fancy Indexing
Original file line number Diff line number Diff line change @@ -26,9 +26,10 @@ def read_clipboard(**kwargs): # pragma: no cover
26
26
return read_table (StringIO (text ), ** kwargs )
27
27
28
28
29
- def to_clipboard (obj ): # pragma: no cover
29
+ def to_clipboard (obj , sep = None , ** kwargs ): # pragma: no cover
30
30
"""
31
31
Attempt to write text representation of object to the system clipboard
32
+ The clipboard can be then pasted into Excel for example.
32
33
33
34
Notes
34
35
-----
@@ -38,4 +39,12 @@ def to_clipboard(obj): # pragma: no cover
38
39
- OS X:
39
40
"""
40
41
from pandas .util .clipboard import clipboard_set
41
- clipboard_set (str (obj ))
42
+ try :
43
+ if sep is None :
44
+ sep = '\t '
45
+ buf = StringIO ()
46
+ obj .to_csv (buf ,sep = sep , ** kwargs )
47
+ clipboard_set (buf .getvalue ())
48
+ except :
49
+ clipboard_set (str (obj ))
50
+
Original file line number Diff line number Diff line change @@ -39,12 +39,19 @@ def setUpClass(cls):
39
39
def tearDownClass (cls ):
40
40
del cls .data_types , cls .data
41
41
42
- def check_round_trip_frame (self , data_type ):
42
+ def check_round_trip_frame (self , data_type , sep = None ):
43
43
data = self .data [data_type ]
44
- data .to_clipboard ()
45
- result = read_clipboard ()
44
+ data .to_clipboard (sep = sep )
45
+ if sep is not None :
46
+ result = read_clipboard (sep = sep ,index_col = 0 )
47
+ else :
48
+ result = read_clipboard ()
46
49
tm .assert_frame_equal (data , result , check_dtype = False )
47
50
51
+ def test_round_trip_frame_sep (self ):
52
+ for dt in self .data_types :
53
+ self .check_round_trip_frame (dt ,sep = ',' )
54
+
48
55
def test_round_trip_frame (self ):
49
56
for dt in self .data_types :
50
57
self .check_round_trip_frame (dt )
You can’t perform that action at this time.
0 commit comments