kshri 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.
kshri-0.1.0/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rishabh
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.
kshri-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,23 @@
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 ADDED
@@ -0,0 +1,10 @@
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
+ ```
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kshri"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Rishabh", email="rishabh@example.com" },
10
+ ]
11
+ description = "Kshri: A fun, lightweight array and dataframe library with personality."
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
kshri-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ from .core import Array, DataFrame
2
+ from .crazy import (
3
+ roast,
4
+ vibe_check,
5
+ chaotic_sort,
6
+ time_travel,
7
+ explain_like_im_5,
8
+ indian_format,
9
+ )
10
+
11
+ __version__ = "0.1.0"
12
+ __all__ = [
13
+ "Array",
14
+ "DataFrame",
15
+ "roast",
16
+ "vibe_check",
17
+ "chaotic_sort",
18
+ "time_travel",
19
+ "explain_like_im_5",
20
+ "indian_format",
21
+ ]
@@ -0,0 +1,39 @@
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})"
@@ -0,0 +1,89 @@
1
+ import random
2
+ import statistics
3
+ from .core import Array, DataFrame
4
+
5
+ def roast(df):
6
+ cols = df.columns if isinstance(df, DataFrame) else df
7
+ if not cols:
8
+ return "Empty dataset? Bold strategy."
9
+
10
+ total_rows = len(next(iter(cols.values())))
11
+ missing = sum(1 for col in cols.values() for val in col if val is None)
12
+
13
+ report = [f"Dataset size: {total_rows} rows."]
14
+ if missing > 0:
15
+ report.append(f"Bro, you have {missing} missing values. Did your cat walk on the keyboard?")
16
+ elif total_rows < 5:
17
+ report.append(f"{total_rows} rows? That's not Big Data, that's a sticky note.")
18
+ else:
19
+ report.append("Actually clean data. Did you fake this dataset?")
20
+ return "\n".join(report)
21
+
22
+ def vibe_check(df):
23
+ cols = df.columns if isinstance(df, DataFrame) else df
24
+ warnings = []
25
+ for name, values in cols.items():
26
+ types = {type(v).__name__ for v in values if v is not None}
27
+ if len(types) > 1:
28
+ warnings.append(f"Column '{name}' has mixed vibes (types: {types}).")
29
+ elif "str" in types and any(str(v).isdigit() for v in values if v is not None):
30
+ warnings.append(f"Column '{name}' has numbers hiding as strings!")
31
+ return "\n".join(warnings) if warnings else "Vibe check passed! All columns look consistent."
32
+
33
+ def chaotic_sort(arr, chaos=True, chaos_rate=0.2):
34
+ data = list(arr.data if isinstance(arr, Array) else arr)
35
+ sorted_data = sorted(data)
36
+ if chaos and len(sorted_data) > 1:
37
+ swaps = max(1, int(len(sorted_data) * chaos_rate))
38
+ for _ in range(swaps):
39
+ i, j = random.sample(range(len(sorted_data)), 2)
40
+ sorted_data[i], sorted_data[j] = sorted_data[j], sorted_data[i]
41
+ return Array(sorted_data)
42
+
43
+ def time_travel(df, steps=1):
44
+ if not isinstance(df, DataFrame):
45
+ raise TypeError("time_travel requires a kshri.DataFrame!")
46
+ for _ in range(steps):
47
+ if df._history:
48
+ df.columns = df._history.pop()
49
+ else:
50
+ print("Cannot travel further back—you are at the beginning of time!")
51
+ break
52
+ return df
53
+
54
+ def explain_like_im_5(arr):
55
+ data = [x for x in (arr.data if isinstance(arr, Array) else arr) if isinstance(x, (int, float))]
56
+ if not data:
57
+ return "There are no numbers here for me to explain!"
58
+ avg = statistics.mean(data)
59
+ med = statistics.median(data)
60
+ high = max(data)
61
+ low = min(data)
62
+
63
+ msg = f"Most numbers sit around {med:.1f} (average is {avg:.1f}). The smallest is {low} and the biggest is {high}."
64
+ if high > med * 3 and med > 0:
65
+ msg += f" Watch out: that massive spike at {high} is pulling your average way up!"
66
+ return msg
67
+
68
+ def indian_format(num_or_arr):
69
+ def _format_one(n):
70
+ s, *dec = f"{n}".split(".")
71
+ neg = s.startswith("-")
72
+ if neg:
73
+ s = s[1:]
74
+ if len(s) > 3:
75
+ last3 = s[-3:]
76
+ rest = s[:-3]
77
+ pairs = []
78
+ while len(rest) > 2:
79
+ pairs.append(rest[-2:])
80
+ rest = rest[:-2]
81
+ if rest:
82
+ pairs.append(rest)
83
+ s = ",".join(reversed(pairs)) + "," + last3
84
+ return ("-" if neg else "") + s + ("." + dec[0] if dec else "")
85
+
86
+ if isinstance(num_or_arr, (Array, list)):
87
+ data = num_or_arr.data if isinstance(num_or_arr, Array) else num_or_arr
88
+ return [_format_one(x) for x in data]
89
+ return _format_one(num_or_arr)
@@ -0,0 +1,23 @@
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
+ ```
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/kshri/__init__.py
5
+ src/kshri/core.py
6
+ src/kshri/crazy.py
7
+ src/kshri.egg-info/PKG-INFO
8
+ src/kshri.egg-info/SOURCES.txt
9
+ src/kshri.egg-info/dependency_links.txt
10
+ src/kshri.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ kshri