pandoras 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pandoras-0.1.0/LICENSE +21 -0
- pandoras-0.1.0/PKG-INFO +84 -0
- pandoras-0.1.0/README.md +68 -0
- pandoras-0.1.0/pandoras/__init__.py +7 -0
- pandoras-0.1.0/pandoras/pandoras.py +102 -0
- pandoras-0.1.0/pyproject.toml +19 -0
pandoras-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Arman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pandoras-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pandoras
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Undo/Redo functionality for Pandas DataFrames using Apache Arrow
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: al2m4n
|
|
7
|
+
Author-email: al2m4n@gmail.com
|
|
8
|
+
Requires-Python: >=3.13
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
13
|
+
Requires-Dist: pyarrow (>=19.0.1,<20.0.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# Pandoras 🐼🎭
|
|
17
|
+
**Undo/Redo functionality for Pandas DataFrames using Apache Arrow.**
|
|
18
|
+
|
|
19
|
+
Pandoras extends `pandas.DataFrame` to add **undo/redo capabilities**, allowing you to **revert accidental modifications** easily.
|
|
20
|
+
|
|
21
|
+
## 🚀 Installation
|
|
22
|
+
|
|
23
|
+
You can install `pandoras` via pip:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
pip install pandoras
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 📌 Features
|
|
30
|
+
✔ **Undo and redo modifications** (`drop`, `rename`, `replace`, etc.)
|
|
31
|
+
✔ **Leverages Apache Arrow for efficient state storage**
|
|
32
|
+
✔ **Supports Pandas' native operations**
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 💡 Example Usage
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import pandoras as pd # Now PandorasDataFrame replaces pd.DataFrame
|
|
40
|
+
|
|
41
|
+
# Create a DataFrame
|
|
42
|
+
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, None, 6]})
|
|
43
|
+
|
|
44
|
+
# Drop a column
|
|
45
|
+
df.drop(columns=["B"], inplace=True)
|
|
46
|
+
print("After drop:\n", df)
|
|
47
|
+
|
|
48
|
+
# Undo the drop
|
|
49
|
+
df.undo()
|
|
50
|
+
print("After undo:\n", df)
|
|
51
|
+
|
|
52
|
+
# Redo the drop
|
|
53
|
+
df.redo()
|
|
54
|
+
print("After redo:\n", df)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🔮 Future Improvements
|
|
60
|
+
🚀 **Diff-based state tracking** instead of storing full DataFrame copies
|
|
61
|
+
🚀 **Optimize memory usage** using compression
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 🌜 License
|
|
66
|
+
Pandoras is open-source and licensed under the **MIT License**. Contributions are welcome!
|
|
67
|
+
|
|
68
|
+
## 🤝 Contributing
|
|
69
|
+
1. **Fork** the repo on GitHub
|
|
70
|
+
2. **Clone** it locally
|
|
71
|
+
3. Create a new **feature branch**
|
|
72
|
+
4. Submit a **pull request**
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 🌍 Connect
|
|
77
|
+
📌 **GitHub Repo:** [GitHub Link Here]
|
|
78
|
+
📌 **PyPI Package:** *(Coming Soon)*
|
|
79
|
+
📌 **Author:** [Your Name]
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
🐼 **Pandoras – Making Pandas Undoable!** 🎭
|
|
84
|
+
|
pandoras-0.1.0/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Pandoras 🐼🎭
|
|
2
|
+
**Undo/Redo functionality for Pandas DataFrames using Apache Arrow.**
|
|
3
|
+
|
|
4
|
+
Pandoras extends `pandas.DataFrame` to add **undo/redo capabilities**, allowing you to **revert accidental modifications** easily.
|
|
5
|
+
|
|
6
|
+
## 🚀 Installation
|
|
7
|
+
|
|
8
|
+
You can install `pandoras` via pip:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pip install pandoras
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 📌 Features
|
|
15
|
+
✔ **Undo and redo modifications** (`drop`, `rename`, `replace`, etc.)
|
|
16
|
+
✔ **Leverages Apache Arrow for efficient state storage**
|
|
17
|
+
✔ **Supports Pandas' native operations**
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 💡 Example Usage
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import pandoras as pd # Now PandorasDataFrame replaces pd.DataFrame
|
|
25
|
+
|
|
26
|
+
# Create a DataFrame
|
|
27
|
+
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, None, 6]})
|
|
28
|
+
|
|
29
|
+
# Drop a column
|
|
30
|
+
df.drop(columns=["B"], inplace=True)
|
|
31
|
+
print("After drop:\n", df)
|
|
32
|
+
|
|
33
|
+
# Undo the drop
|
|
34
|
+
df.undo()
|
|
35
|
+
print("After undo:\n", df)
|
|
36
|
+
|
|
37
|
+
# Redo the drop
|
|
38
|
+
df.redo()
|
|
39
|
+
print("After redo:\n", df)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🔮 Future Improvements
|
|
45
|
+
🚀 **Diff-based state tracking** instead of storing full DataFrame copies
|
|
46
|
+
🚀 **Optimize memory usage** using compression
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🌜 License
|
|
51
|
+
Pandoras is open-source and licensed under the **MIT License**. Contributions are welcome!
|
|
52
|
+
|
|
53
|
+
## 🤝 Contributing
|
|
54
|
+
1. **Fork** the repo on GitHub
|
|
55
|
+
2. **Clone** it locally
|
|
56
|
+
3. Create a new **feature branch**
|
|
57
|
+
4. Submit a **pull request**
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🌍 Connect
|
|
62
|
+
📌 **GitHub Repo:** [GitHub Link Here]
|
|
63
|
+
📌 **PyPI Package:** *(Coming Soon)*
|
|
64
|
+
📌 **Author:** [Your Name]
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
🐼 **Pandoras – Making Pandas Undoable!** 🎭
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import pyarrow as pa
|
|
4
|
+
from collections import deque
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
logger.addHandler(logging.NullHandler())
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PandorasDataFrame(pd.DataFrame):
|
|
11
|
+
"""Custom Pandas DataFrame with Undo/Redo functionality using pyarrow."""
|
|
12
|
+
|
|
13
|
+
_metadata = ["_history", "_future", "_max_history"]
|
|
14
|
+
|
|
15
|
+
def __init__(self, *args, max_history=10, **kwargs):
|
|
16
|
+
super().__init__(*args, **kwargs)
|
|
17
|
+
self._history = deque(maxlen=max_history) # Stores past versions
|
|
18
|
+
self._future = deque(maxlen=max_history) # Stores redo versions
|
|
19
|
+
self._max_history = max_history
|
|
20
|
+
|
|
21
|
+
def _store_state(self):
|
|
22
|
+
"""Save current DataFrame state as an Arrow Table before modification."""
|
|
23
|
+
self._history.append(pa.Table.from_pandas(self, preserve_index=True))
|
|
24
|
+
self._future.clear() # Clear redo stack when new change is made
|
|
25
|
+
|
|
26
|
+
def _restore_state(self, df):
|
|
27
|
+
self.__dict__.update(df.__dict__)
|
|
28
|
+
|
|
29
|
+
def undo(self):
|
|
30
|
+
"""Revert to the previous state if available."""
|
|
31
|
+
if not self._history:
|
|
32
|
+
logger.warning("No more undo steps available.")
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
self._future.append(pa.Table.from_pandas(self, preserve_index=True)) # Save current state for redo
|
|
36
|
+
prev_state = self._history.pop() # Get previous version
|
|
37
|
+
restored_df = prev_state.to_pandas() # Convert back to Pandas
|
|
38
|
+
|
|
39
|
+
self._restore_state(restored_df)
|
|
40
|
+
|
|
41
|
+
def redo(self):
|
|
42
|
+
"""Redo an undone operation."""
|
|
43
|
+
if not self._future:
|
|
44
|
+
logger.warning("No more redo steps available.")
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
self._history.append(pa.Table.from_pandas(self, preserve_index=True)) # Save current state for undo
|
|
48
|
+
next_state = self._future.pop() # Get redo version
|
|
49
|
+
restored_df = next_state.to_pandas() # Convert back to Pandas
|
|
50
|
+
|
|
51
|
+
self._restore_state(restored_df)
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def history_size(self):
|
|
55
|
+
"""Return the number of stored undo steps."""
|
|
56
|
+
return len(self._history)
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def future_size(self):
|
|
60
|
+
"""Return the number of stored redo steps."""
|
|
61
|
+
return len(self._future)
|
|
62
|
+
|
|
63
|
+
def clear_history(self):
|
|
64
|
+
"""Clear undo and redo history."""
|
|
65
|
+
self._history.clear()
|
|
66
|
+
self._future.clear()
|
|
67
|
+
|
|
68
|
+
# Override Pandas modification functions to track changes
|
|
69
|
+
def drop(self, *args, **kwargs):
|
|
70
|
+
self._store_state()
|
|
71
|
+
return super().drop(*args, **kwargs)
|
|
72
|
+
|
|
73
|
+
def rename(self, *args, **kwargs):
|
|
74
|
+
self._store_state()
|
|
75
|
+
return super().rename(*args, **kwargs)
|
|
76
|
+
|
|
77
|
+
def replace(self, *args, **kwargs): # noqa
|
|
78
|
+
self._store_state()
|
|
79
|
+
return super().replace(*args, **kwargs)
|
|
80
|
+
|
|
81
|
+
def reset_index(self, *args, **kwargs):
|
|
82
|
+
self._store_state()
|
|
83
|
+
return super().reset_index(*args, **kwargs)
|
|
84
|
+
|
|
85
|
+
def set_index(self, *args, **kwargs):
|
|
86
|
+
self._store_state()
|
|
87
|
+
return super().set_index(*args, **kwargs)
|
|
88
|
+
|
|
89
|
+
def fillna(self, *args, **kwargs): # noqa
|
|
90
|
+
self._store_state()
|
|
91
|
+
return super().fillna(*args, **kwargs)
|
|
92
|
+
|
|
93
|
+
def assign(self, **kwargs):
|
|
94
|
+
self._store_state()
|
|
95
|
+
return super().assign(**kwargs)
|
|
96
|
+
|
|
97
|
+
def apply(self, *args, **kwargs):
|
|
98
|
+
self._store_state()
|
|
99
|
+
return super().apply(*args, **kwargs)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
__all__ = ["PandorasDataFrame"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pandoras"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Undo/Redo functionality for Pandas DataFrames using Apache Arrow"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "al2m4n",email = "al2m4n@gmail.com"}
|
|
7
|
+
]
|
|
8
|
+
license = "MIT"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
repository = "https://github.com/al2m4n/pandoras"
|
|
11
|
+
requires-python = ">=3.13"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"pandas (>=2.2.3,<3.0.0)",
|
|
14
|
+
"pyarrow (>=19.0.1,<20.0.0)"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
19
|
+
build-backend = "poetry.core.masonry.api"
|