Python | Панды dataframe.to_clipboard ()
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas dataframe.to_clipboard() function copy object to the system clipboard. This function writes a text representation of the object to the system clipboard. This could be easily pasted into excel or notepad++.
Syntax: DataFrame.to_clipboard(excel=True, sep=None, **kwargs)
Parameters :
excel : True, use the provided separator, writing in a csv format for allowing easy pasting into excel. False, write a string representation of the object to the clipboard.
sep : Field delimiter.
**kwargs : These parameters will be passed to DataFrame.to_csv.
Примечание. Для ссылки на CSV-файл, использованный в коде, щелкните здесь.
Example #1: Use to_clipboard() function to copy the object to the clipboard in a non-excel format.
# importing pandas as pdimport pandas as pd # Creating the dataframe df = pd.read_csv("nba.csv") # Print the dataframedf |
Выход :
Now we will copy this object to clipboard in a non-excel format.
# copy to clipboarddf.to_clipboard(excel = False, sep = ", ") |
Output :
We have simply pasted, what got copied to the clipboard after executing the previous command. The software used was “Notepad++”.
Example #2: Use to_clipboard() function to copy the object to the clipboard in an excel format.
# importing pandas as pdimport pandas as pd # Creating the dataframe df = pd.read_csv("nba.csv") # Print the dataframedf |
Выход :
Now we will copy this object to clipboard in an excel format.
# copy to clipboarddf.to_clipboard(excel = True) |
Выход :
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.