Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scwilkinson/pd-replicator
Copy a pandas DataFrame to the clipboard with one click
https://github.com/scwilkinson/pd-replicator
jupyter jupyterlab pandas
Last synced: 28 days ago
JSON representation
Copy a pandas DataFrame to the clipboard with one click
- Host: GitHub
- URL: https://github.com/scwilkinson/pd-replicator
- Owner: scwilkinson
- License: gpl-3.0
- Created: 2020-04-11T22:09:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-16T17:10:37.000Z (over 4 years ago)
- Last Synced: 2024-05-07T19:33:42.884Z (7 months ago)
- Topics: jupyter, jupyterlab, pandas
- Language: Python
- Homepage:
- Size: 258 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-jupyter - pd-replicator - Copy a pandas DataFrame to the clipboard with one click. (Visualization)
README
# pd-replicator
[![PyPI Downloads](https://img.shields.io/pypi/dm/pd-replicator?color=blue)](https://pypi.org/project/pd-replicator/)
[![Awesome Jupyter](https://awesome.re/mentioned-badge.svg)](https://github.com/markusschanta/awesome-jupyter#readme)Copy a pandas DataFrame to the clipboard with one click
![Jupyter Demo](images/jupyter-demo.png)
## Installation
Installation can be done through `pip`:
```sh
> pip install pd-replicator
````ipywidgets` must be setup in order for the button/dropdown to display correctly:
```sh
> pip install ipywidgets
> jupyter nbextension enable --py widgetsnbextension
```To use with JupyterLab, an additional step is required:
```sh
> jupyter labextension install @jupyter-widgets/jupyterlab-manager
```## Usage
`pd-replicator` can be used in classic Jupyter, JupyterLab, and Google Colaboratory.
It can be used on both local and remotely hosted instances (such as AWS SageMaker or JupyterHub).
### Enabling the Copy Button
Wrap `replicator()` around any `pandas` DataFrame/Series to display the replicator copy button above the DataFrame/Series:
```python
from pd_replicator import replicatorreplicator(df)
```For remotely hosted instances, the `native` option should be set to `False`:
```python
from pd_replicator import replicatorreplicator(df, native=False)
```This uses JavaScript to copy to the clipboard through your browser, rather than the system copy method used by `pandas.to_clipboard()`.
### Using the Copy Button
Clicking the "Copy" button will copy the associated DataFrame/Series to your clipboard in tab-seperated form. This means the DataFrame/Series can be pasted directly into Excel or Google Sheets without needing to split the text.
For example, selecting a single cell and pasting will result in something like this:
![Excel Paste Demo](images/excel-paste-demo.png)
### Using the Dropdown
The dropdown allows some control over what is copied to your clipboard when you press the "Copy" button.
![Dropdown Demo](images/dropdown-demo.png)
You can choose to exclude the index, header, or both from being copied.