PySide6Pandas
PySide6Pandas is a Python module that contains classes for extending Pandas to integrate with PySide6, based off of PyQt5Pandas. It provides utilities to use Pandas DataFrames in PySide6 applications, including custom table models for displaying and editing data in QTableView, as well as dialogs for importing data from CSV files and other formats.
## Features
- **Pandas DataFrame Integration**: Custom QAbstractTableModel implementations for seamless display of Pandas DataFrames in PySide6's QTableView.
- **Editable Views**: Support for editing DataFrame cells directly in the GUI, with changes reflected back to the underlying DataFrame.
- **Data Import Dialogs**: Dialogs like CSVImportDialog for loading data into DataFrames from files.
- **Sorting and Filtering**: Built-in support for sorting columns and filtering rows within the view.
- **Extensible Classes**: Easily subclass models and views for custom behaviors.
- **Cross-Platform Compatibility**: Works on Windows, macOS, and Linux with PySide6.
- **Performance Optimized**: Efficient handling of large DataFrames with lazy loading and virtualization.
## Installation
You can install PySide6Pandas via pip:
```bash
pip install pyside6pandas
```
Alternatively, clone the repository and install from source:
```bash
git clone https://github.com/<USER_OR_ORG>/pyside6pandas.git
cd pyside6pandas
pip install -e .
```
### Requirements
- Python 3.<MIN_VERSION> or higher
- Dependencies: pyside6, pandas (automatically installed via pip where applicable)
## Quick Start
Import the module, create a DataFrameModel, and display it in a QTableView:
```python
import sys
from PySide6.QtWidgets import QApplication, QTableView
import pandas as pd
from pyside6pandas.models import DataFrameModel
app = QApplication(sys.argv)
df = pd.DataFrame({'Name': ['Alice', 'Bob'], 'Age': [30, 25]})
model = DataFrameModel(df)
view = QTableView()
view.setModel(model)
view.show()
sys.exit(app.exec())
```
## Usage
### Creating a DataFrameModel
The core class is DataFrameModel, which extends QAbstractTableModel:
```python
from pyside6pandas.models import DataFrameModel
df = pd.DataFrame(data=[[1, 2], [3, 4]], columns=['Col1', 'Col2'])
model = DataFrameModel(df, editable=True)
# Use model with QTableView
```
### Using Data Import Dialogs
Import data via dialogs:
```python
from pyside6pandas.views import CSVImportDialog
dialog = CSVImportDialog()
if dialog.exec():
df = dialog.getDataFrame()
# Use the imported DataFrame
```
### Advanced Views
Extend or use provided views for additional functionality:
```python
from pyside6pandas.views import DataFrameView
view = DataFrameView()
view.setDataFrame(df)
view.show()
```
## Examples
### Example 1: Basic DataFrame Display
```python
import sys
from PySide6.QtWidgets import QApplication, QMainWindow
import pandas as pd
from pyside6pandas.models import DataFrameModel
from pyside6pandas.views import DataFrameView
app = QApplication(sys.argv)
window = QMainWindow()
df = pd.read_csv('data.csv')
view = DataFrameView()
view.setDataFrame(df)
window.setCentralWidget(view)
window.show()
sys.exit(app.exec())
```
### Example 2: Editable DataFrame with Saving
```python
import sys
from PySide6.QtWidgets import QApplication, QTableView, QPushButton, QVBoxLayout, QWidget
import pandas as pd
from pyside6pandas.models import DataFrameModel
app = QApplication(sys.argv)
df = pd.DataFrame({'Item': ['A', 'B'], 'Price': [10.5, 20.0]})
model = DataFrameModel(df, editable=True)
view = QTableView()
view.setModel(model)
save_button = QPushButton('Save Changes')
save_button.clicked.connect(lambda: df.to_csv('updated.csv'))
layout = QVBoxLayout()
layout.addWidget(view)
layout.addWidget(save_button)
widget = QWidget()
widget.setLayout(layout)
widget.show()
sys.exit(app.exec())
```
## Configuration Guide
Customize models with options like:
- `editable`: Boolean to enable editing (default: False)
- `sortable`: Boolean to enable column sorting (default: True)
- `custom_formatters`: Dictionary for column-specific formatting
For advanced customization, refer to the [docs/config-reference.md](docs/config-reference.md).
## Contributing
Contributions are welcome! Please follow these steps:
1. Fork the repository.
2. Create a feature branch (`git checkout -b feature/<FEATURE_NAME>`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin feature/<FEATURE_NAME>`).
5. Open a Pull Request.
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
## License
This project is licensed under the <LICENSE_TYPE> License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
- Based on the concepts from PyQt5Pandas for PyQt5 integration.
- Thanks to contributors of underlying libraries like PySide6, pandas.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyside6pandas-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: pyside6pandas-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60dac7c7d333081be5686ad0c2237691633c51b0bc5a81a8ac34c60369803b47
|
|
| MD5 |
3ae9c03b20417a398ee6e05d0d82d737
|
|
| BLAKE2b-256 |
59ab1ce9b86c6059602de43a269e8c08d9009356b1b2910207a3e20efc07e550
|