Installation
- python -m pip install drawdata
To read the data, polars is useful, but this library also suppots pandas:
- python -m pip install pandas polars
Basic Usage
You can load the scatter widget to start drawing immediately:
- from drawdata import ScatterWidget
- widget = ScatterWidget()
- widget
Once you've drawn your data, you can access it as:
- A list of dictionaries: widget.data
- A Pandas DataFrame: widget.data_as_pandas
- A Polars DataFrame: widget.data_as_polars
- Features and labels for machine learning: X, y = widget.data_as_X_y
The tool recognizes multiple colors for classification tasks, while a single color is used for regression.
Using the Old Feature
To use the old feature in Jupyter, load it within an iframe:
- from drawdata import draw_scatter
- draw_scatter()
After drawing, copy the data to the clipboard. You can then use pandas to import it into a DataFrame:
- import pandas as pd
- pd.read_clipboard(sep=",")
Additional Information
Originally developed at Calmcode Labs, this library has evolved from using iframes to leveraging anywidget for better integration and usability.
For more details, visit the GitHub repository.