kshri 0.1.0__tar.gz → 0.2.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.
- kshri-0.2.0/PKG-INFO +94 -0
- kshri-0.2.0/README.md +78 -0
- {kshri-0.1.0 → kshri-0.2.0}/pyproject.toml +8 -2
- {kshri-0.1.0 → kshri-0.2.0}/src/kshri/__init__.py +11 -1
- kshri-0.2.0/src/kshri/core.py +91 -0
- kshri-0.2.0/src/kshri/modern.py +56 -0
- kshri-0.2.0/src/kshri.egg-info/PKG-INFO +94 -0
- {kshri-0.1.0 → kshri-0.2.0}/src/kshri.egg-info/SOURCES.txt +1 -0
- kshri-0.1.0/PKG-INFO +0 -23
- kshri-0.1.0/README.md +0 -10
- kshri-0.1.0/src/kshri/core.py +0 -39
- kshri-0.1.0/src/kshri.egg-info/PKG-INFO +0 -23
- {kshri-0.1.0 → kshri-0.2.0}/LICENSE +0 -0
- {kshri-0.1.0 → kshri-0.2.0}/setup.cfg +0 -0
- {kshri-0.1.0 → kshri-0.2.0}/src/kshri/crazy.py +0 -0
- {kshri-0.1.0 → kshri-0.2.0}/src/kshri.egg-info/dependency_links.txt +0 -0
- {kshri-0.1.0 → kshri-0.2.0}/src/kshri.egg-info/top_level.txt +0 -0
kshri-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kshri
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Kshri: A fun, lightweight array and dataframe library with personality.
|
|
5
|
+
Author-email: Rishabh <rishabh@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/24f3003274-RISHABH/kshri
|
|
8
|
+
Project-URL: Repository, https://github.com/24f3003274-RISHABH/kshri
|
|
9
|
+
Project-URL: Issues, https://github.com
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# Kshri
|
|
18
|
+
|
|
19
|
+
[](https://pypi.org)
|
|
20
|
+
[](https://opensource.org)
|
|
21
|
+
|
|
22
|
+
**Kshri** is a lightweight Python array and DataFrame library built with personality, human-readable insights, and Indian number formatting.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
```bash
|
|
26
|
+
pip install kshri
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Project Structure
|
|
30
|
+
```text
|
|
31
|
+
kshri-project/
|
|
32
|
+
├── pyproject.toml # Build configuration & PyPI metadata
|
|
33
|
+
├── README.md # Main documentation
|
|
34
|
+
├── LICENSE # MIT Open-Source License
|
|
35
|
+
└── src/
|
|
36
|
+
└── kshri/
|
|
37
|
+
├── __init__.py # Public exports (Array, DataFrame, all functions)
|
|
38
|
+
├── core.py # Core Array and DataFrame classes
|
|
39
|
+
└── crazy.py # Data inspection, time_travel, and formatting tools
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Functions & Usage
|
|
43
|
+
|
|
44
|
+
### 1. `roast(df)`
|
|
45
|
+
Scans a `DataFrame` or dictionary for missing values and tiny datasets, returning a brutally honest summary.
|
|
46
|
+
```python
|
|
47
|
+
from kshri import DataFrame, roast
|
|
48
|
+
|
|
49
|
+
df = DataFrame({"name": ["Rishabh", "Aman"], "score": [95, None]})
|
|
50
|
+
print(roast(df))
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. `time_travel(df, steps=1)`
|
|
54
|
+
Reverts changes (`drop`, column edits) made to a `kshri.DataFrame`.
|
|
55
|
+
```python
|
|
56
|
+
from kshri import DataFrame, time_travel
|
|
57
|
+
|
|
58
|
+
df = DataFrame({"a":, "b": [3, 4]})
|
|
59
|
+
df.drop("b")
|
|
60
|
+
time_travel(df) # Restores column "b"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. `vibe_check(df)`
|
|
64
|
+
Detects mixed data types or numbers accidentally stored as strings inside columns.
|
|
65
|
+
```python
|
|
66
|
+
from kshri import DataFrame, vibe_check
|
|
67
|
+
|
|
68
|
+
df = DataFrame({"age": ["21", "25"]})
|
|
69
|
+
print(vibe_check(df))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. `indian_format(num_or_arr)`
|
|
73
|
+
Formats numbers or `Array` items using the Indian numbering system (Lakhs and Crores).
|
|
74
|
+
```python
|
|
75
|
+
from kshri import indian_format
|
|
76
|
+
|
|
77
|
+
print(indian_format(12500000)) # "1,25,00,000"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 5. `explain_like_im_5(arr)`
|
|
81
|
+
Summarizes median, mean, range, and extreme outliers in plain English.
|
|
82
|
+
```python
|
|
83
|
+
from kshri import Array, explain_like_im_5
|
|
84
|
+
|
|
85
|
+
print(explain_like_im_5(Array([10, 12, 11, 500])))
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 6. `chaotic_sort(arr, chaos=True, chaos_rate=0.2)`
|
|
89
|
+
Sorts an array while optionally swapping a small percentage of elements for stress-testing pipelines.
|
|
90
|
+
```python
|
|
91
|
+
from kshri import chaotic_sort
|
|
92
|
+
|
|
93
|
+
print(chaotic_sort([5, 1, 4, 2, 3]))
|
|
94
|
+
```
|
kshri-0.2.0/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Kshri
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org)
|
|
4
|
+
[](https://opensource.org)
|
|
5
|
+
|
|
6
|
+
**Kshri** is a lightweight Python array and DataFrame library built with personality, human-readable insights, and Indian number formatting.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
```bash
|
|
10
|
+
pip install kshri
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Project Structure
|
|
14
|
+
```text
|
|
15
|
+
kshri-project/
|
|
16
|
+
├── pyproject.toml # Build configuration & PyPI metadata
|
|
17
|
+
├── README.md # Main documentation
|
|
18
|
+
├── LICENSE # MIT Open-Source License
|
|
19
|
+
└── src/
|
|
20
|
+
└── kshri/
|
|
21
|
+
├── __init__.py # Public exports (Array, DataFrame, all functions)
|
|
22
|
+
├── core.py # Core Array and DataFrame classes
|
|
23
|
+
└── crazy.py # Data inspection, time_travel, and formatting tools
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Functions & Usage
|
|
27
|
+
|
|
28
|
+
### 1. `roast(df)`
|
|
29
|
+
Scans a `DataFrame` or dictionary for missing values and tiny datasets, returning a brutally honest summary.
|
|
30
|
+
```python
|
|
31
|
+
from kshri import DataFrame, roast
|
|
32
|
+
|
|
33
|
+
df = DataFrame({"name": ["Rishabh", "Aman"], "score": [95, None]})
|
|
34
|
+
print(roast(df))
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. `time_travel(df, steps=1)`
|
|
38
|
+
Reverts changes (`drop`, column edits) made to a `kshri.DataFrame`.
|
|
39
|
+
```python
|
|
40
|
+
from kshri import DataFrame, time_travel
|
|
41
|
+
|
|
42
|
+
df = DataFrame({"a":, "b": [3, 4]})
|
|
43
|
+
df.drop("b")
|
|
44
|
+
time_travel(df) # Restores column "b"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. `vibe_check(df)`
|
|
48
|
+
Detects mixed data types or numbers accidentally stored as strings inside columns.
|
|
49
|
+
```python
|
|
50
|
+
from kshri import DataFrame, vibe_check
|
|
51
|
+
|
|
52
|
+
df = DataFrame({"age": ["21", "25"]})
|
|
53
|
+
print(vibe_check(df))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 4. `indian_format(num_or_arr)`
|
|
57
|
+
Formats numbers or `Array` items using the Indian numbering system (Lakhs and Crores).
|
|
58
|
+
```python
|
|
59
|
+
from kshri import indian_format
|
|
60
|
+
|
|
61
|
+
print(indian_format(12500000)) # "1,25,00,000"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 5. `explain_like_im_5(arr)`
|
|
65
|
+
Summarizes median, mean, range, and extreme outliers in plain English.
|
|
66
|
+
```python
|
|
67
|
+
from kshri import Array, explain_like_im_5
|
|
68
|
+
|
|
69
|
+
print(explain_like_im_5(Array([10, 12, 11, 500])))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 6. `chaotic_sort(arr, chaos=True, chaos_rate=0.2)`
|
|
73
|
+
Sorts an array while optionally swapping a small percentage of elements for stress-testing pipelines.
|
|
74
|
+
```python
|
|
75
|
+
from kshri import chaotic_sort
|
|
76
|
+
|
|
77
|
+
print(chaotic_sort([5, 1, 4, 2, 3]))
|
|
78
|
+
```
|
|
@@ -4,15 +4,21 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "kshri"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Rishabh", email="rishabh@example.com" },
|
|
10
10
|
]
|
|
11
11
|
description = "Kshri: A fun, lightweight array and dataframe library with personality."
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.8"
|
|
14
|
+
license = "MIT"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
14
16
|
classifiers = [
|
|
15
17
|
"Programming Language :: Python :: 3",
|
|
16
|
-
"License :: OSI Approved :: MIT License",
|
|
17
18
|
"Operating System :: OS Independent",
|
|
18
19
|
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/24f3003274-RISHABH/kshri"
|
|
23
|
+
Repository = "https://github.com/24f3003274-RISHABH/kshri"
|
|
24
|
+
Issues = "https://github.com"
|
|
@@ -7,8 +7,14 @@ from .crazy import (
|
|
|
7
7
|
explain_like_im_5,
|
|
8
8
|
indian_format,
|
|
9
9
|
)
|
|
10
|
+
from .modern import (
|
|
11
|
+
bar_chart,
|
|
12
|
+
quick_predict,
|
|
13
|
+
cosine_similarity,
|
|
14
|
+
to_llm_prompt,
|
|
15
|
+
)
|
|
10
16
|
|
|
11
|
-
__version__ = "0.
|
|
17
|
+
__version__ = "0.2.0"
|
|
12
18
|
__all__ = [
|
|
13
19
|
"Array",
|
|
14
20
|
"DataFrame",
|
|
@@ -18,4 +24,8 @@ __all__ = [
|
|
|
18
24
|
"time_travel",
|
|
19
25
|
"explain_like_im_5",
|
|
20
26
|
"indian_format",
|
|
27
|
+
"bar_chart",
|
|
28
|
+
"quick_predict",
|
|
29
|
+
"cosine_similarity",
|
|
30
|
+
"to_llm_prompt",
|
|
21
31
|
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
import csv
|
|
3
|
+
import statistics
|
|
4
|
+
|
|
5
|
+
class Array:
|
|
6
|
+
"""A lightweight 1D numerical array with built-in math operations."""
|
|
7
|
+
def __init__(self, data):
|
|
8
|
+
self.data = list(data)
|
|
9
|
+
|
|
10
|
+
def sum(self):
|
|
11
|
+
return sum(x for x in self.data if isinstance(x, (int, float)))
|
|
12
|
+
|
|
13
|
+
def mean(self):
|
|
14
|
+
nums = [x for x in self.data if isinstance(x, (int, float))]
|
|
15
|
+
return statistics.mean(nums) if nums else 0.0
|
|
16
|
+
|
|
17
|
+
def std(self):
|
|
18
|
+
nums = [x for x in self.data if isinstance(x, (int, float))]
|
|
19
|
+
return statistics.stdev(nums) if len(nums) > 1 else 0.0
|
|
20
|
+
|
|
21
|
+
def __add__(self, other):
|
|
22
|
+
if isinstance(other, Array):
|
|
23
|
+
return Array([a + b for a, b in zip(self.data, other.data)])
|
|
24
|
+
return Array([a + other for a in self.data])
|
|
25
|
+
|
|
26
|
+
def __mul__(self, other):
|
|
27
|
+
if isinstance(other, Array):
|
|
28
|
+
return Array([a * b for a, b in zip(self.data, other.data)])
|
|
29
|
+
return Array([a * other for a in self.data])
|
|
30
|
+
|
|
31
|
+
def __repr__(self):
|
|
32
|
+
return f"kshri.Array({self.data})"
|
|
33
|
+
|
|
34
|
+
def __len__(self):
|
|
35
|
+
return len(self.data)
|
|
36
|
+
|
|
37
|
+
def __getitem__(self, idx):
|
|
38
|
+
return self.data[idx]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class DataFrame:
|
|
42
|
+
"""A lightweight DataFrame with CSV support, auto-cleaning, and time-travel."""
|
|
43
|
+
def __init__(self, data_dict):
|
|
44
|
+
self.columns = {k: list(v) for k, v in data_dict.items()}
|
|
45
|
+
self._history = []
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def read_csv(cls, filepath):
|
|
49
|
+
"""Load a CSV file directly into a kshri.DataFrame with auto-number parsing."""
|
|
50
|
+
with open(filepath, mode="r", encoding="utf-8") as f:
|
|
51
|
+
reader = csv.DictReader(f)
|
|
52
|
+
cols = {field: [] for field in (reader.fieldnames or [])}
|
|
53
|
+
for row in reader:
|
|
54
|
+
for k, v in row.items():
|
|
55
|
+
if v == "" or v is None:
|
|
56
|
+
cols[k].append(None)
|
|
57
|
+
else:
|
|
58
|
+
try:
|
|
59
|
+
cols[k].append(float(v) if "." in v else int(v))
|
|
60
|
+
except ValueError:
|
|
61
|
+
cols[k].append(v)
|
|
62
|
+
return cls(cols)
|
|
63
|
+
|
|
64
|
+
def _save_snapshot(self):
|
|
65
|
+
self._history.append(copy.deepcopy(self.columns))
|
|
66
|
+
|
|
67
|
+
def auto_clean(self):
|
|
68
|
+
"""Automatically fill missing numbers with median and missing text with 'Unknown'."""
|
|
69
|
+
self._save_snapshot()
|
|
70
|
+
for col, vals in self.columns.items():
|
|
71
|
+
nums = [x for x in vals if isinstance(x, (int, float))]
|
|
72
|
+
fill_val = statistics.median(nums) if nums else "Unknown"
|
|
73
|
+
self.columns[col] = [fill_val if v is None else v for v in vals]
|
|
74
|
+
return self
|
|
75
|
+
|
|
76
|
+
def drop(self, col_name):
|
|
77
|
+
"""Remove a column while saving a snapshot for time_travel()."""
|
|
78
|
+
if col_name in self.columns:
|
|
79
|
+
self._save_snapshot()
|
|
80
|
+
del self.columns[col_name]
|
|
81
|
+
return self
|
|
82
|
+
|
|
83
|
+
def __getitem__(self, col_name):
|
|
84
|
+
return Array(self.columns[col_name])
|
|
85
|
+
|
|
86
|
+
def __setitem__(self, col_name, values):
|
|
87
|
+
self._save_snapshot()
|
|
88
|
+
self.columns[col_name] = list(values)
|
|
89
|
+
|
|
90
|
+
def __repr__(self):
|
|
91
|
+
return f"kshri.DataFrame({self.columns})"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import statistics
|
|
3
|
+
from .core import Array, DataFrame
|
|
4
|
+
|
|
5
|
+
def bar_chart(labels, values, width=25):
|
|
6
|
+
"""Render a clean instant bar chart right in the terminal or Colab."""
|
|
7
|
+
vals = list(values.data if isinstance(values, Array) else values)
|
|
8
|
+
lbls = list(labels.data if isinstance(labels, Array) else labels)
|
|
9
|
+
if not vals:
|
|
10
|
+
return "No data to plot."
|
|
11
|
+
max_val = max(vals) or 1
|
|
12
|
+
lines = []
|
|
13
|
+
for label, val in zip(lbls, vals):
|
|
14
|
+
bar_len = int((val / max_val) * width)
|
|
15
|
+
bar = "█" * bar_len
|
|
16
|
+
lines.append(f"{str(label):<12} | {bar} {val}")
|
|
17
|
+
chart = "\n".join(lines)
|
|
18
|
+
print(chart)
|
|
19
|
+
return chart
|
|
20
|
+
|
|
21
|
+
def quick_predict(x_vals, y_vals, predict_for):
|
|
22
|
+
"""1-line Linear Regression: trains on (x, y) and predicts a new value."""
|
|
23
|
+
x = list(x_vals.data if isinstance(x_vals, Array) else x_vals)
|
|
24
|
+
y = list(y_vals.data if isinstance(y_vals, Array) else y_vals)
|
|
25
|
+
if len(x) != len(y) or len(x) < 2:
|
|
26
|
+
raise ValueError("Need at least 2 matching data points to train!")
|
|
27
|
+
|
|
28
|
+
mean_x, mean_y = statistics.mean(x), statistics.mean(y)
|
|
29
|
+
numerator = sum((xi - mean_x) * (yi - mean_y) for xi, yi in zip(x, y))
|
|
30
|
+
denominator = sum((xi - mean_x) ** 2 for xi in x) or 1e-9
|
|
31
|
+
|
|
32
|
+
slope = numerator / denominator
|
|
33
|
+
intercept = mean_y - slope * mean_x
|
|
34
|
+
prediction = slope * predict_for + intercept
|
|
35
|
+
return round(prediction, 4)
|
|
36
|
+
|
|
37
|
+
def cosine_similarity(vec1, vec2):
|
|
38
|
+
"""Compute AI embedding similarity (-1 to 1) for RAG and semantic search."""
|
|
39
|
+
v1 = list(vec1.data if isinstance(vec1, Array) else vec1)
|
|
40
|
+
v2 = list(vec2.data if isinstance(vec2, Array) else vec2)
|
|
41
|
+
dot = sum(a * b for a, b in zip(v1, v2))
|
|
42
|
+
mag1 = math.sqrt(sum(a * a for a in v1))
|
|
43
|
+
mag2 = math.sqrt(sum(b * b for b in v2))
|
|
44
|
+
if mag1 == 0 or mag2 == 0:
|
|
45
|
+
return 0.0
|
|
46
|
+
return round(dot / (mag1 * mag2), 4)
|
|
47
|
+
|
|
48
|
+
def to_llm_prompt(df, question="Summarize key insights from this data:"):
|
|
49
|
+
"""Convert a DataFrame into a clean, token-efficient Markdown table for LLMs."""
|
|
50
|
+
cols = df.columns if isinstance(df, DataFrame) else df
|
|
51
|
+
headers = list(cols.keys())
|
|
52
|
+
rows = zip(*cols.values())
|
|
53
|
+
table = ["| " + " | ".join(headers) + " |", "| " + " | ".join(["---"] * len(headers)) + " |"]
|
|
54
|
+
for row in rows:
|
|
55
|
+
table.append("| " + " | ".join(str(x) for x in row) + " |")
|
|
56
|
+
return f"{question}\n\n" + "\n".join(table)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kshri
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Kshri: A fun, lightweight array and dataframe library with personality.
|
|
5
|
+
Author-email: Rishabh <rishabh@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/24f3003274-RISHABH/kshri
|
|
8
|
+
Project-URL: Repository, https://github.com/24f3003274-RISHABH/kshri
|
|
9
|
+
Project-URL: Issues, https://github.com
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# Kshri
|
|
18
|
+
|
|
19
|
+
[](https://pypi.org)
|
|
20
|
+
[](https://opensource.org)
|
|
21
|
+
|
|
22
|
+
**Kshri** is a lightweight Python array and DataFrame library built with personality, human-readable insights, and Indian number formatting.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
```bash
|
|
26
|
+
pip install kshri
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Project Structure
|
|
30
|
+
```text
|
|
31
|
+
kshri-project/
|
|
32
|
+
├── pyproject.toml # Build configuration & PyPI metadata
|
|
33
|
+
├── README.md # Main documentation
|
|
34
|
+
├── LICENSE # MIT Open-Source License
|
|
35
|
+
└── src/
|
|
36
|
+
└── kshri/
|
|
37
|
+
├── __init__.py # Public exports (Array, DataFrame, all functions)
|
|
38
|
+
├── core.py # Core Array and DataFrame classes
|
|
39
|
+
└── crazy.py # Data inspection, time_travel, and formatting tools
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Functions & Usage
|
|
43
|
+
|
|
44
|
+
### 1. `roast(df)`
|
|
45
|
+
Scans a `DataFrame` or dictionary for missing values and tiny datasets, returning a brutally honest summary.
|
|
46
|
+
```python
|
|
47
|
+
from kshri import DataFrame, roast
|
|
48
|
+
|
|
49
|
+
df = DataFrame({"name": ["Rishabh", "Aman"], "score": [95, None]})
|
|
50
|
+
print(roast(df))
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. `time_travel(df, steps=1)`
|
|
54
|
+
Reverts changes (`drop`, column edits) made to a `kshri.DataFrame`.
|
|
55
|
+
```python
|
|
56
|
+
from kshri import DataFrame, time_travel
|
|
57
|
+
|
|
58
|
+
df = DataFrame({"a":, "b": [3, 4]})
|
|
59
|
+
df.drop("b")
|
|
60
|
+
time_travel(df) # Restores column "b"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. `vibe_check(df)`
|
|
64
|
+
Detects mixed data types or numbers accidentally stored as strings inside columns.
|
|
65
|
+
```python
|
|
66
|
+
from kshri import DataFrame, vibe_check
|
|
67
|
+
|
|
68
|
+
df = DataFrame({"age": ["21", "25"]})
|
|
69
|
+
print(vibe_check(df))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. `indian_format(num_or_arr)`
|
|
73
|
+
Formats numbers or `Array` items using the Indian numbering system (Lakhs and Crores).
|
|
74
|
+
```python
|
|
75
|
+
from kshri import indian_format
|
|
76
|
+
|
|
77
|
+
print(indian_format(12500000)) # "1,25,00,000"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 5. `explain_like_im_5(arr)`
|
|
81
|
+
Summarizes median, mean, range, and extreme outliers in plain English.
|
|
82
|
+
```python
|
|
83
|
+
from kshri import Array, explain_like_im_5
|
|
84
|
+
|
|
85
|
+
print(explain_like_im_5(Array([10, 12, 11, 500])))
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 6. `chaotic_sort(arr, chaos=True, chaos_rate=0.2)`
|
|
89
|
+
Sorts an array while optionally swapping a small percentage of elements for stress-testing pipelines.
|
|
90
|
+
```python
|
|
91
|
+
from kshri import chaotic_sort
|
|
92
|
+
|
|
93
|
+
print(chaotic_sort([5, 1, 4, 2, 3]))
|
|
94
|
+
```
|
kshri-0.1.0/PKG-INFO
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: kshri
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Kshri: A fun, lightweight array and dataframe library with personality.
|
|
5
|
-
Author-email: Rishabh <rishabh@example.com>
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.8
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Dynamic: license-file
|
|
13
|
-
|
|
14
|
-
# Kshri
|
|
15
|
-
A lightweight Python data library with personality (`roast`, `time_travel`, `vibe_check`, `indian_format`, and more).
|
|
16
|
-
|
|
17
|
-
## Quickstart
|
|
18
|
-
```python
|
|
19
|
-
from kshri import DataFrame, roast, time_travel, indian_format
|
|
20
|
-
|
|
21
|
-
df = DataFrame({"name": ["Rishabh", "Aman"], "score": [95, None]})
|
|
22
|
-
print(roast(df))
|
|
23
|
-
```
|
kshri-0.1.0/README.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Kshri
|
|
2
|
-
A lightweight Python data library with personality (`roast`, `time_travel`, `vibe_check`, `indian_format`, and more).
|
|
3
|
-
|
|
4
|
-
## Quickstart
|
|
5
|
-
```python
|
|
6
|
-
from kshri import DataFrame, roast, time_travel, indian_format
|
|
7
|
-
|
|
8
|
-
df = DataFrame({"name": ["Rishabh", "Aman"], "score": [95, None]})
|
|
9
|
-
print(roast(df))
|
|
10
|
-
```
|
kshri-0.1.0/src/kshri/core.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import copy
|
|
2
|
-
|
|
3
|
-
class Array:
|
|
4
|
-
def __init__(self, data):
|
|
5
|
-
self.data = list(data)
|
|
6
|
-
|
|
7
|
-
def __repr__(self):
|
|
8
|
-
return f"kshri.Array({self.data})"
|
|
9
|
-
|
|
10
|
-
def __len__(self):
|
|
11
|
-
return len(self.data)
|
|
12
|
-
|
|
13
|
-
def __getitem__(self, idx):
|
|
14
|
-
return self.data[idx]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class DataFrame:
|
|
18
|
-
def __init__(self, data_dict):
|
|
19
|
-
self.columns = {k: list(v) for k, v in data_dict.items()}
|
|
20
|
-
self._history = []
|
|
21
|
-
|
|
22
|
-
def _save_snapshot(self):
|
|
23
|
-
self._history.append(copy.deepcopy(self.columns))
|
|
24
|
-
|
|
25
|
-
def drop(self, col_name):
|
|
26
|
-
if col_name in self.columns:
|
|
27
|
-
self._save_snapshot()
|
|
28
|
-
del self.columns[col_name]
|
|
29
|
-
return self
|
|
30
|
-
|
|
31
|
-
def __getitem__(self, col_name):
|
|
32
|
-
return Array(self.columns[col_name])
|
|
33
|
-
|
|
34
|
-
def __setitem__(self, col_name, values):
|
|
35
|
-
self._save_snapshot()
|
|
36
|
-
self.columns[col_name] = list(values)
|
|
37
|
-
|
|
38
|
-
def __repr__(self):
|
|
39
|
-
return f"kshri.DataFrame({self.columns})"
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: kshri
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Kshri: A fun, lightweight array and dataframe library with personality.
|
|
5
|
-
Author-email: Rishabh <rishabh@example.com>
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.8
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Dynamic: license-file
|
|
13
|
-
|
|
14
|
-
# Kshri
|
|
15
|
-
A lightweight Python data library with personality (`roast`, `time_travel`, `vibe_check`, `indian_format`, and more).
|
|
16
|
-
|
|
17
|
-
## Quickstart
|
|
18
|
-
```python
|
|
19
|
-
from kshri import DataFrame, roast, time_travel, indian_format
|
|
20
|
-
|
|
21
|
-
df = DataFrame({"name": ["Rishabh", "Aman"], "score": [95, None]})
|
|
22
|
-
print(roast(df))
|
|
23
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|