Python | Pandas Series.to_clipboard()
Last Updated :
05 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.to_clipboard()
function copy object to the system clipboard. It write a text representation of object to the system clipboard. This can be pasted into Excel as well.
Syntax: Series.to_clipboard(excel=True, sep=None, **kwargs)
Parameter :
excel : bool, default True
sep : str, default ‘\t’
**kwargs : These parameters will be passed to DataFrame.to_csv.
Returns : None
Example #1: Use Series.to_clipboard()
function to copy the given Series object to the systems clipboard.
import pandas as pd
sr = pd.Series([ 'New York' , 'Chicago' , 'Toronto' , 'Lisbon' , 'Rio' , 'Moscow' ])
didx = pd.DatetimeIndex(start = '2014-08-01 10:00' , freq = 'W' ,
periods = 6 , tz = 'Europe/Berlin' )
sr.index = didx
print (sr)
|
Output :
Now we will use Series.to_clipboard()
function to copy the given series object to the systems clipboard.
Output :
After executing the last line of code we simply pasted what was copied to the system’s clipboard in Notepad++. This is what it looks like.
Example #2: Use Series.to_clipboard()
function to copy the given Series object to the systems clipboard.
import pandas as pd
sr = pd.Series([ 19.5 , 16.8 , None , 22.78 , None , 20.124 , None , 18.1002 , None ])
print (sr)
|
Output :
Now we will use Series.to_clipboard()
function to copy the given series object to the systems clipboard.
Output :
After executing the last line of code we simply pasted what was copied to the system’s clipboard in Notepad++. This is what it looks like. Notice how missing values has been represented as blanks.
Share your thoughts in the comments
Please Login to comment...