smilo 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.
- smilo-0.1.0/LICENSE +0 -0
- smilo-0.1.0/PKG-INFO +51 -0
- smilo-0.1.0/README.md +35 -0
- smilo-0.1.0/pyproject.toml +29 -0
- smilo-0.1.0/setup.cfg +4 -0
- smilo-0.1.0/smilo/__init__.py +7 -0
- smilo-0.1.0/smilo/clean.py +31 -0
- smilo-0.1.0/smilo/split.py +47 -0
- smilo-0.1.0/smilo/stats.py +75 -0
- smilo-0.1.0/smilo/utils.py +45 -0
- smilo-0.1.0/smilo/viz.py +43 -0
- smilo-0.1.0/smilo.egg-info/PKG-INFO +51 -0
- smilo-0.1.0/smilo.egg-info/SOURCES.txt +15 -0
- smilo-0.1.0/smilo.egg-info/dependency_links.txt +1 -0
- smilo-0.1.0/smilo.egg-info/requires.txt +3 -0
- smilo-0.1.0/smilo.egg-info/top_level.txt +1 -0
- smilo-0.1.0/tests/test_smilo.py +85 -0
smilo-0.1.0/LICENSE
ADDED
|
File without changes
|
smilo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smilo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A beginner-friendly Python data analysis library.
|
|
5
|
+
Author-email: Fahad <dr.fahad1001@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/smilo
|
|
8
|
+
Project-URL: Repository, https://github.com/yourusername/smilo
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: numpy>=1.24
|
|
13
|
+
Requires-Dist: pandas>=2.0
|
|
14
|
+
Requires-Dist: matplotlib>=3.7
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# smilo
|
|
18
|
+
|
|
19
|
+
A beginner-friendly Python data analysis library for cleaning, splitting, exploring, and visualizing data.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
pip install smilo
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
from smilo.clean import remove_nulls
|
|
28
|
+
from smilo.split import train_test_split
|
|
29
|
+
from smilo.stats import mean, median, standard_deviation
|
|
30
|
+
from smilo.utils import load_csv, dataset_info
|
|
31
|
+
from smilo.viz import quick_hist
|
|
32
|
+
|
|
33
|
+
data = [1, None, 2, None, 3]
|
|
34
|
+
clean_data = remove_nulls(data)
|
|
35
|
+
print(clean_data) # [1, 2, 3]
|
|
36
|
+
|
|
37
|
+
train, test = train_test_split([1,2,3,4,5,6,7,8,9,10], test_size=0.2, seed=42)
|
|
38
|
+
|
|
39
|
+
print(mean([1, 2, 3, 4, 5])) # 3.0
|
|
40
|
+
|
|
41
|
+
## Modules
|
|
42
|
+
|
|
43
|
+
- **clean.py** — remove_nulls, fill_nulls, remove_duplicates, remove_empty_strings
|
|
44
|
+
- **split.py** — train_test_split, k_fold_split
|
|
45
|
+
- **stats.py** — mean, median, mode, minimum, maximum, data_range, total, count, variance, standard_deviation
|
|
46
|
+
- **utils.py** — load_csv, dataset_info, column_types
|
|
47
|
+
- **viz.py** — quick_hist, quick_corr
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
smilo-0.1.0/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# smilo
|
|
2
|
+
|
|
3
|
+
A beginner-friendly Python data analysis library for cleaning, splitting, exploring, and visualizing data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
pip install smilo
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
from smilo.clean import remove_nulls
|
|
12
|
+
from smilo.split import train_test_split
|
|
13
|
+
from smilo.stats import mean, median, standard_deviation
|
|
14
|
+
from smilo.utils import load_csv, dataset_info
|
|
15
|
+
from smilo.viz import quick_hist
|
|
16
|
+
|
|
17
|
+
data = [1, None, 2, None, 3]
|
|
18
|
+
clean_data = remove_nulls(data)
|
|
19
|
+
print(clean_data) # [1, 2, 3]
|
|
20
|
+
|
|
21
|
+
train, test = train_test_split([1,2,3,4,5,6,7,8,9,10], test_size=0.2, seed=42)
|
|
22
|
+
|
|
23
|
+
print(mean([1, 2, 3, 4, 5])) # 3.0
|
|
24
|
+
|
|
25
|
+
## Modules
|
|
26
|
+
|
|
27
|
+
- **clean.py** — remove_nulls, fill_nulls, remove_duplicates, remove_empty_strings
|
|
28
|
+
- **split.py** — train_test_split, k_fold_split
|
|
29
|
+
- **stats.py** — mean, median, mode, minimum, maximum, data_range, total, count, variance, standard_deviation
|
|
30
|
+
- **utils.py** — load_csv, dataset_info, column_types
|
|
31
|
+
- **viz.py** — quick_hist, quick_corr
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
MIT
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "smilo"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A beginner-friendly Python data analysis library."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Fahad", email = "dr.fahad1001@gmail.com" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
dependencies = [
|
|
18
|
+
"numpy>=1.24",
|
|
19
|
+
"pandas>=2.0",
|
|
20
|
+
"matplotlib>=3.7"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/yourusername/smilo"
|
|
25
|
+
Repository = "https://github.com/yourusername/smilo"
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["."]
|
|
29
|
+
include = ["smilo*"]
|
smilo-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Data Cleaning Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
def remove_nulls(data):
|
|
7
|
+
"""
|
|
8
|
+
Remove None values from a list.
|
|
9
|
+
"""
|
|
10
|
+
return [item for item in data if item is not None]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def fill_nulls(data, value=0):
|
|
14
|
+
"""
|
|
15
|
+
Replace None values with a specified value.
|
|
16
|
+
"""
|
|
17
|
+
return [value if item is None else item for item in data]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def remove_duplicates(data):
|
|
21
|
+
"""
|
|
22
|
+
Remove duplicate values while preserving order.
|
|
23
|
+
"""
|
|
24
|
+
return list(dict.fromkeys(data))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def remove_empty_strings(data):
|
|
28
|
+
"""
|
|
29
|
+
Remove empty strings from a list.
|
|
30
|
+
"""
|
|
31
|
+
return [item for item in data if item != ""]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Data Splitting Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import random
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def train_test_split(data, test_size=0.2, seed=None):
|
|
10
|
+
"""
|
|
11
|
+
Split a list of data into train and test sets.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
data (list): The dataset to split.
|
|
15
|
+
test_size (float): Proportion of data to use as test set (0-1).
|
|
16
|
+
seed (int): Optional random seed for reproducibility.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
tuple: (train_data, test_data)
|
|
20
|
+
"""
|
|
21
|
+
if seed is not None:
|
|
22
|
+
random.seed(seed)
|
|
23
|
+
|
|
24
|
+
shuffled = data.copy()
|
|
25
|
+
random.shuffle(shuffled)
|
|
26
|
+
|
|
27
|
+
split_index = int(len(shuffled) * (1 - test_size))
|
|
28
|
+
train_data = shuffled[:split_index]
|
|
29
|
+
test_data = shuffled[split_index:]
|
|
30
|
+
|
|
31
|
+
return train_data, test_data
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def k_fold_split(data, k=5):
|
|
35
|
+
"""
|
|
36
|
+
Split data into k equal-sized folds for cross-validation.
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
data (list): The dataset to split.
|
|
40
|
+
k (int): Number of folds.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
list of lists: k folds of data.
|
|
44
|
+
"""
|
|
45
|
+
fold_size = len(data) // k
|
|
46
|
+
folds = [data[i * fold_size:(i + 1) * fold_size] for i in range(k)]
|
|
47
|
+
return folds
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Statistics Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from collections import Counter
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def mean(data):
|
|
10
|
+
"""Return the average of a list."""
|
|
11
|
+
if not data:
|
|
12
|
+
raise ValueError("Data cannot be empty.")
|
|
13
|
+
return sum(data) / len(data)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def median(data):
|
|
17
|
+
"""Return the median of a list."""
|
|
18
|
+
if not data:
|
|
19
|
+
raise ValueError("Data cannot be empty.")
|
|
20
|
+
|
|
21
|
+
data = sorted(data)
|
|
22
|
+
n = len(data)
|
|
23
|
+
mid = n // 2
|
|
24
|
+
|
|
25
|
+
if n % 2 == 0:
|
|
26
|
+
return (data[mid - 1] + data[mid]) / 2
|
|
27
|
+
return data[mid]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def mode(data):
|
|
31
|
+
"""Return the most frequent value."""
|
|
32
|
+
if not data:
|
|
33
|
+
raise ValueError("Data cannot be empty.")
|
|
34
|
+
|
|
35
|
+
count = Counter(data)
|
|
36
|
+
return count.most_common(1)[0][0]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def minimum(data):
|
|
40
|
+
"""Return the minimum value."""
|
|
41
|
+
return min(data)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def maximum(data):
|
|
45
|
+
"""Return the maximum value."""
|
|
46
|
+
return max(data)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def data_range(data):
|
|
50
|
+
"""Return the range (max - min)."""
|
|
51
|
+
return max(data) - min(data)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def total(data):
|
|
55
|
+
"""Return the sum of all values."""
|
|
56
|
+
return sum(data)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def count(data):
|
|
60
|
+
"""Return the number of values."""
|
|
61
|
+
return len(data)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def variance(data):
|
|
65
|
+
"""Return the population variance."""
|
|
66
|
+
if not data:
|
|
67
|
+
raise ValueError("Data cannot be empty.")
|
|
68
|
+
|
|
69
|
+
avg = mean(data)
|
|
70
|
+
return sum((x - avg) ** 2 for x in data) / len(data)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def standard_deviation(data):
|
|
74
|
+
"""Return the population standard deviation."""
|
|
75
|
+
return variance(data) ** 0.5
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Utilities Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def load_csv(filepath):
|
|
10
|
+
"""
|
|
11
|
+
Load a CSV file into a pandas DataFrame.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
filepath (str): Path to the CSV file.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
pd.DataFrame: Loaded data.
|
|
18
|
+
"""
|
|
19
|
+
return pd.read_csv(filepath)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def dataset_info(df):
|
|
23
|
+
"""
|
|
24
|
+
Print a quick summary of a DataFrame: shape, columns, missing values.
|
|
25
|
+
|
|
26
|
+
Parameters:
|
|
27
|
+
df (pd.DataFrame): The dataset to inspect.
|
|
28
|
+
"""
|
|
29
|
+
print(f"Shape: {df.shape}")
|
|
30
|
+
print(f"Columns: {list(df.columns)}")
|
|
31
|
+
print("Missing values per column:")
|
|
32
|
+
print(df.isnull().sum())
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def column_types(df):
|
|
36
|
+
"""
|
|
37
|
+
Return a dictionary of column names and their data types.
|
|
38
|
+
|
|
39
|
+
Parameters:
|
|
40
|
+
df (pd.DataFrame): The dataset to inspect.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
dict: {column_name: dtype}
|
|
44
|
+
"""
|
|
45
|
+
return df.dtypes.astype(str).to_dict()
|
smilo-0.1.0/smilo/viz.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Visualization Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import matplotlib.pyplot as plt
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def quick_hist(data, column, bins=20, title=None):
|
|
10
|
+
"""
|
|
11
|
+
Plot a quick histogram for a DataFrame column.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
data (pd.DataFrame): The dataset.
|
|
15
|
+
column (str): Column name to plot.
|
|
16
|
+
bins (int): Number of histogram bins.
|
|
17
|
+
title (str): Optional plot title.
|
|
18
|
+
"""
|
|
19
|
+
plt.figure(figsize=(8, 5))
|
|
20
|
+
plt.hist(data[column].dropna(), bins=bins, color="skyblue", edgecolor="black")
|
|
21
|
+
plt.title(title or f"Distribution of {column}")
|
|
22
|
+
plt.xlabel(column)
|
|
23
|
+
plt.ylabel("Frequency")
|
|
24
|
+
plt.show()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def quick_corr(data, title="Correlation Heatmap"):
|
|
28
|
+
"""
|
|
29
|
+
Plot a correlation heatmap for numeric columns in a DataFrame.
|
|
30
|
+
|
|
31
|
+
Parameters:
|
|
32
|
+
data (pd.DataFrame): The dataset.
|
|
33
|
+
title (str): Plot title.
|
|
34
|
+
"""
|
|
35
|
+
corr = data.corr(numeric_only=True)
|
|
36
|
+
plt.figure(figsize=(8, 6))
|
|
37
|
+
plt.imshow(corr, cmap="coolwarm", interpolation="none")
|
|
38
|
+
plt.colorbar()
|
|
39
|
+
plt.xticks(range(len(corr.columns)), corr.columns, rotation=90)
|
|
40
|
+
plt.yticks(range(len(corr.columns)), corr.columns)
|
|
41
|
+
plt.title(title)
|
|
42
|
+
plt.tight_layout()
|
|
43
|
+
plt.show()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smilo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A beginner-friendly Python data analysis library.
|
|
5
|
+
Author-email: Fahad <dr.fahad1001@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/smilo
|
|
8
|
+
Project-URL: Repository, https://github.com/yourusername/smilo
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: numpy>=1.24
|
|
13
|
+
Requires-Dist: pandas>=2.0
|
|
14
|
+
Requires-Dist: matplotlib>=3.7
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# smilo
|
|
18
|
+
|
|
19
|
+
A beginner-friendly Python data analysis library for cleaning, splitting, exploring, and visualizing data.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
pip install smilo
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
from smilo.clean import remove_nulls
|
|
28
|
+
from smilo.split import train_test_split
|
|
29
|
+
from smilo.stats import mean, median, standard_deviation
|
|
30
|
+
from smilo.utils import load_csv, dataset_info
|
|
31
|
+
from smilo.viz import quick_hist
|
|
32
|
+
|
|
33
|
+
data = [1, None, 2, None, 3]
|
|
34
|
+
clean_data = remove_nulls(data)
|
|
35
|
+
print(clean_data) # [1, 2, 3]
|
|
36
|
+
|
|
37
|
+
train, test = train_test_split([1,2,3,4,5,6,7,8,9,10], test_size=0.2, seed=42)
|
|
38
|
+
|
|
39
|
+
print(mean([1, 2, 3, 4, 5])) # 3.0
|
|
40
|
+
|
|
41
|
+
## Modules
|
|
42
|
+
|
|
43
|
+
- **clean.py** — remove_nulls, fill_nulls, remove_duplicates, remove_empty_strings
|
|
44
|
+
- **split.py** — train_test_split, k_fold_split
|
|
45
|
+
- **stats.py** — mean, median, mode, minimum, maximum, data_range, total, count, variance, standard_deviation
|
|
46
|
+
- **utils.py** — load_csv, dataset_info, column_types
|
|
47
|
+
- **viz.py** — quick_hist, quick_corr
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
smilo/__init__.py
|
|
5
|
+
smilo/clean.py
|
|
6
|
+
smilo/split.py
|
|
7
|
+
smilo/stats.py
|
|
8
|
+
smilo/utils.py
|
|
9
|
+
smilo/viz.py
|
|
10
|
+
smilo.egg-info/PKG-INFO
|
|
11
|
+
smilo.egg-info/SOURCES.txt
|
|
12
|
+
smilo.egg-info/dependency_links.txt
|
|
13
|
+
smilo.egg-info/requires.txt
|
|
14
|
+
smilo.egg-info/top_level.txt
|
|
15
|
+
tests/test_smilo.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
smilo
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for the smilo library
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
from smilo.clean import remove_nulls, fill_nulls, remove_duplicates, remove_empty_strings
|
|
9
|
+
from smilo.split import train_test_split, k_fold_split
|
|
10
|
+
from smilo.stats import (
|
|
11
|
+
mean, median, mode, minimum, maximum,
|
|
12
|
+
data_range, total, count, variance, standard_deviation
|
|
13
|
+
)
|
|
14
|
+
from smilo.utils import load_csv, dataset_info, column_types
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# ---------- clean.py ----------
|
|
18
|
+
|
|
19
|
+
def test_remove_nulls():
|
|
20
|
+
assert remove_nulls([1, None, 2, None, 3]) == [1, 2, 3]
|
|
21
|
+
|
|
22
|
+
def test_fill_nulls():
|
|
23
|
+
assert fill_nulls([1, None, 2], value=0) == [1, 0, 2]
|
|
24
|
+
|
|
25
|
+
def test_remove_duplicates():
|
|
26
|
+
assert remove_duplicates([1, 2, 2, 3, 1]) == [1, 2, 3]
|
|
27
|
+
|
|
28
|
+
def test_remove_empty_strings():
|
|
29
|
+
assert remove_empty_strings(["a", "", "b", ""]) == ["a", "b"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# ---------- split.py ----------
|
|
33
|
+
|
|
34
|
+
def test_train_test_split():
|
|
35
|
+
train, test = train_test_split([1,2,3,4,5,6,7,8,9,10], test_size=0.2, seed=42)
|
|
36
|
+
assert len(train) == 8
|
|
37
|
+
assert len(test) == 2
|
|
38
|
+
|
|
39
|
+
def test_k_fold_split():
|
|
40
|
+
folds = k_fold_split([1,2,3,4,5,6,7,8,9,10], k=5)
|
|
41
|
+
assert len(folds) == 5
|
|
42
|
+
assert all(len(fold) == 2 for fold in folds)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# ---------- stats.py ----------
|
|
46
|
+
|
|
47
|
+
def test_mean():
|
|
48
|
+
assert mean([1, 2, 3, 4, 5]) == 3.0
|
|
49
|
+
|
|
50
|
+
def test_median():
|
|
51
|
+
assert median([1, 2, 3, 4, 5]) == 3
|
|
52
|
+
assert median([1, 2, 3, 4]) == 2.5
|
|
53
|
+
|
|
54
|
+
def test_mode():
|
|
55
|
+
assert mode([1, 2, 2, 3]) == 2
|
|
56
|
+
|
|
57
|
+
def test_minimum():
|
|
58
|
+
assert minimum([4, 1, 7, 2]) == 1
|
|
59
|
+
|
|
60
|
+
def test_maximum():
|
|
61
|
+
assert maximum([4, 1, 7, 2]) == 7
|
|
62
|
+
|
|
63
|
+
def test_data_range():
|
|
64
|
+
assert data_range([4, 1, 7, 2]) == 6
|
|
65
|
+
|
|
66
|
+
def test_total():
|
|
67
|
+
assert total([1, 2, 3]) == 6
|
|
68
|
+
|
|
69
|
+
def test_count():
|
|
70
|
+
assert count([1, 2, 3, 4]) == 4
|
|
71
|
+
|
|
72
|
+
def test_variance():
|
|
73
|
+
assert variance([2, 4, 4, 4, 5, 5, 7, 9]) == 4.0
|
|
74
|
+
|
|
75
|
+
def test_standard_deviation():
|
|
76
|
+
assert round(standard_deviation([2, 4, 4, 4, 5, 5, 7, 9]), 2) == 2.0
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# ---------- utils.py ----------
|
|
80
|
+
|
|
81
|
+
def test_column_types():
|
|
82
|
+
df = pd.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})
|
|
83
|
+
types = column_types(df)
|
|
84
|
+
assert types["a"] == "int64"
|
|
85
|
+
assert types["b"] == "str"
|