nummpyy 1.0.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.
- nummpyy-1.0.0/LICENSE +21 -0
- nummpyy-1.0.0/PKG-INFO +115 -0
- nummpyy-1.0.0/README.md +92 -0
- nummpyy-1.0.0/nummpyy/__init__.py +35 -0
- nummpyy-1.0.0/nummpyy/assesssuperstep.py +55 -0
- nummpyy-1.0.0/nummpyy/averagelatitude.py +30 -0
- nummpyy-1.0.0/nummpyy/correlation.py +43 -0
- nummpyy-1.0.0/nummpyy/datascience.py +58 -0
- nummpyy-1.0.0/nummpyy/edges.py +36 -0
- nummpyy-1.0.0/nummpyy/extraspaces.py +21 -0
- nummpyy-1.0.0/nummpyy/fixedlatitude.py +39 -0
- nummpyy-1.0.0/nummpyy/histogram.py +47 -0
- nummpyy-1.0.0/nummpyy/horus.py +36 -0
- nummpyy-1.0.0/nummpyy/hough.py +50 -0
- nummpyy-1.0.0/nummpyy/multichannel.py +36 -0
- nummpyy-1.0.0/nummpyy/nlp.py +49 -0
- nummpyy-1.0.0/nummpyy/reformatting.py +25 -0
- nummpyy-1.0.0/nummpyy/removing.py +22 -0
- nummpyy-1.0.0/nummpyy/retrievesuperstep.py +37 -0
- nummpyy-1.0.0/nummpyy/structured.py +58 -0
- nummpyy-1.0.0/nummpyy/supervised.py +68 -0
- nummpyy-1.0.0/nummpyy/thumbnail.py +41 -0
- nummpyy-1.0.0/nummpyy/unsupervised.py +109 -0
- nummpyy-1.0.0/nummpyy/visualization.py +86 -0
- nummpyy-1.0.0/nummpyy.egg-info/PKG-INFO +115 -0
- nummpyy-1.0.0/nummpyy.egg-info/SOURCES.txt +29 -0
- nummpyy-1.0.0/nummpyy.egg-info/dependency_links.txt +1 -0
- nummpyy-1.0.0/nummpyy.egg-info/entry_points.txt +2 -0
- nummpyy-1.0.0/nummpyy.egg-info/top_level.txt +1 -0
- nummpyy-1.0.0/setup.cfg +4 -0
- nummpyy-1.0.0/setup.py +31 -0
nummpyy-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chirag Vishwakarma
|
|
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.
|
nummpyy-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nummpyy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Data Science practical programs, printable from Python or the terminal
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: andhrew
|
|
7
|
+
Author-email: xyz@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: license
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
# nummpyy
|
|
25
|
+
|
|
26
|
+
A Python package that stores **Data Science** practical programs and prints their source code on demand, from Python or the terminal.
|
|
27
|
+
|
|
28
|
+
Install it once with `pip`, then view any practical on any machine without copying files around.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Practicals included
|
|
33
|
+
|
|
34
|
+
Pass any of these names (without `.py`) to `show_codes()` or the `nummpyy` command:
|
|
35
|
+
|
|
36
|
+
| | | |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `assesssuperstep` | `averagelatitude` | `correlation` |
|
|
39
|
+
| `datascience` | `edges` | `extraspaces` |
|
|
40
|
+
| `fixedlatitude` | `histogram` | `horus` |
|
|
41
|
+
| `hough` | `multichannel` | `nlp` |
|
|
42
|
+
| `reformatting` | `removing` | `retrievesuperstep` |
|
|
43
|
+
| `structured` | `supervised` | `thumbnail` |
|
|
44
|
+
| `unsupervised` | `visualization` | |
|
|
45
|
+
|
|
46
|
+
The programs use `numpy`, `pandas` and `matplotlib`. Install those yourself if you want to run them; `nummpyy` only prints them.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install nummpyy
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Upgrade:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install --upgrade nummpyy
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Requires Python 3.6 or newer.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## View the programs
|
|
67
|
+
|
|
68
|
+
### From the terminal
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
nummpyy # show all practicals
|
|
72
|
+
nummpyy correlation # show one practical
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### From Python
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import nummpyy
|
|
79
|
+
|
|
80
|
+
nummpyy.show_codes() # show all practicals
|
|
81
|
+
nummpyy.show_codes("correlation") # show one practical
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### In Google Colab or Jupyter
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
!pip install nummpyy
|
|
88
|
+
import nummpyy
|
|
89
|
+
nummpyy.show_codes("hough")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Publishing a new version (for maintainers)
|
|
95
|
+
|
|
96
|
+
1. Add or update files in the `nummpyy/` folder.
|
|
97
|
+
2. Increase `version` in `setup.py` (e.g. `1.0.1`). PyPI never accepts the same version twice.
|
|
98
|
+
3. Clean old builds:
|
|
99
|
+
```bash
|
|
100
|
+
rm -rf dist build *.egg-info
|
|
101
|
+
```
|
|
102
|
+
4. Build:
|
|
103
|
+
```bash
|
|
104
|
+
python3 -m build
|
|
105
|
+
```
|
|
106
|
+
5. Upload to PyPI (username `__token__`, password is your `pypi-...` API token):
|
|
107
|
+
```bash
|
|
108
|
+
python3 -m twine upload dist/*
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT. See [LICENSE](LICENSE).
|
nummpyy-1.0.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# nummpyy
|
|
2
|
+
|
|
3
|
+
A Python package that stores **Data Science** practical programs and prints their source code on demand, from Python or the terminal.
|
|
4
|
+
|
|
5
|
+
Install it once with `pip`, then view any practical on any machine without copying files around.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Practicals included
|
|
10
|
+
|
|
11
|
+
Pass any of these names (without `.py`) to `show_codes()` or the `nummpyy` command:
|
|
12
|
+
|
|
13
|
+
| | | |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `assesssuperstep` | `averagelatitude` | `correlation` |
|
|
16
|
+
| `datascience` | `edges` | `extraspaces` |
|
|
17
|
+
| `fixedlatitude` | `histogram` | `horus` |
|
|
18
|
+
| `hough` | `multichannel` | `nlp` |
|
|
19
|
+
| `reformatting` | `removing` | `retrievesuperstep` |
|
|
20
|
+
| `structured` | `supervised` | `thumbnail` |
|
|
21
|
+
| `unsupervised` | `visualization` | |
|
|
22
|
+
|
|
23
|
+
The programs use `numpy`, `pandas` and `matplotlib`. Install those yourself if you want to run them; `nummpyy` only prints them.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install nummpyy
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Upgrade:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install --upgrade nummpyy
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Requires Python 3.6 or newer.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## View the programs
|
|
44
|
+
|
|
45
|
+
### From the terminal
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
nummpyy # show all practicals
|
|
49
|
+
nummpyy correlation # show one practical
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### From Python
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import nummpyy
|
|
56
|
+
|
|
57
|
+
nummpyy.show_codes() # show all practicals
|
|
58
|
+
nummpyy.show_codes("correlation") # show one practical
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### In Google Colab or Jupyter
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
!pip install nummpyy
|
|
65
|
+
import nummpyy
|
|
66
|
+
nummpyy.show_codes("hough")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Publishing a new version (for maintainers)
|
|
72
|
+
|
|
73
|
+
1. Add or update files in the `nummpyy/` folder.
|
|
74
|
+
2. Increase `version` in `setup.py` (e.g. `1.0.1`). PyPI never accepts the same version twice.
|
|
75
|
+
3. Clean old builds:
|
|
76
|
+
```bash
|
|
77
|
+
rm -rf dist build *.egg-info
|
|
78
|
+
```
|
|
79
|
+
4. Build:
|
|
80
|
+
```bash
|
|
81
|
+
python3 -m build
|
|
82
|
+
```
|
|
83
|
+
5. Upload to PyPI (username `__token__`, password is your `pypi-...` API token):
|
|
84
|
+
```bash
|
|
85
|
+
python3 -m twine upload dist/*
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
def show_codes(filename: str = None):
|
|
5
|
+
"""
|
|
6
|
+
Displays code included in this package.
|
|
7
|
+
- If filename is given (without .py), shows that file's code.
|
|
8
|
+
- If no filename is given, shows all .py files.
|
|
9
|
+
"""
|
|
10
|
+
base_path = os.path.dirname(__file__)
|
|
11
|
+
files = [f for f in os.listdir(base_path) if f.endswith(".py") and f != "__init__.py"]
|
|
12
|
+
|
|
13
|
+
if filename:
|
|
14
|
+
file_path = os.path.join(base_path, f"{filename}.py")
|
|
15
|
+
if os.path.exists(file_path):
|
|
16
|
+
print(f"\n=== Showing {filename}.py ===\n")
|
|
17
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
18
|
+
print(f.read())
|
|
19
|
+
else:
|
|
20
|
+
print(f"\n❌ File '{filename}.py' not found in this package.\n")
|
|
21
|
+
print("Available files:")
|
|
22
|
+
for f in files:
|
|
23
|
+
print("•", f.replace(".py", ""))
|
|
24
|
+
else:
|
|
25
|
+
print("\nAll practical codes:\n")
|
|
26
|
+
for f in files:
|
|
27
|
+
print(f"\n=== {f} ===\n")
|
|
28
|
+
with open(os.path.join(base_path, f), "r", encoding="utf-8") as file:
|
|
29
|
+
print(file.read())
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def main():
|
|
33
|
+
"""Command-line entry point: nummpyy [filename]"""
|
|
34
|
+
filename = " ".join(sys.argv[1:]) or None
|
|
35
|
+
show_codes(filename)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
+
except NameError:
|
|
8
|
+
BASE = os.getcwd()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def path(name):
|
|
12
|
+
return os.path.join(BASE, name)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _fruit_df():
|
|
16
|
+
return pd.DataFrame(
|
|
17
|
+
[[10, np.nan, 30, 40],
|
|
18
|
+
[7, 14, 21, 28],
|
|
19
|
+
[55, np.nan, 8, 12],
|
|
20
|
+
[15, 14, np.nan, 8],
|
|
21
|
+
[7, 1, 1, np.nan],
|
|
22
|
+
[np.nan, 4, 9, 2]],
|
|
23
|
+
columns=["Apple", "Orange", "Banana", "Pear"],
|
|
24
|
+
index=["Basket1", "Basket2", "Basket3", "Basket4", "Basket5", "Basket6"])
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def p6():
|
|
28
|
+
print("#################################")
|
|
29
|
+
print("THE ORIGINAL VALUES")
|
|
30
|
+
print(_fruit_df())
|
|
31
|
+
|
|
32
|
+
df = _fruit_df()
|
|
33
|
+
print("\nREPLACING THE VALUES WITH MEAN")
|
|
34
|
+
df.fillna(df.mean(), inplace=True)
|
|
35
|
+
print(df)
|
|
36
|
+
|
|
37
|
+
df = _fruit_df()
|
|
38
|
+
print("\nREPLACING THE VALUES WITH MEDIAN")
|
|
39
|
+
df.fillna(df.median(), inplace=True)
|
|
40
|
+
print(df)
|
|
41
|
+
|
|
42
|
+
df = _fruit_df()
|
|
43
|
+
print("\nREPLACING THE VALUES WITH MODE")
|
|
44
|
+
for column in df.columns:
|
|
45
|
+
df[column] = df[column].fillna(df[column].mode()[0])
|
|
46
|
+
print(df)
|
|
47
|
+
|
|
48
|
+
df = _fruit_df()
|
|
49
|
+
print("\nREPLACING THE VALUES WITH MINIMUM")
|
|
50
|
+
df.fillna(df.min(), inplace=True)
|
|
51
|
+
print(df)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
p6()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
except NameError:
|
|
7
|
+
BASE = os.getcwd()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def path(name):
|
|
11
|
+
return os.path.join(BASE, name)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load_ip_data():
|
|
15
|
+
df = pd.read_csv(path("IP_DATA_ALL.csv"), header=0, low_memory=False,
|
|
16
|
+
encoding="latin-1",
|
|
17
|
+
usecols=["Country", "Place.Name", "Latitude", "Longitude"])
|
|
18
|
+
df.rename(columns={"Place.Name": "Place_Name"}, inplace=True)
|
|
19
|
+
return df
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def p2e():
|
|
23
|
+
IP_DATA_ALL = load_ip_data()
|
|
24
|
+
small = IP_DATA_ALL[["Country", "Place_Name", "Latitude"]]
|
|
25
|
+
AverageLatitude = small.groupby(["Country", "Place_Name"])["Latitude"].mean()
|
|
26
|
+
print(AverageLatitude)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
p2e()
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
+
except NameError:
|
|
8
|
+
BASE = os.getcwd()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def path(name):
|
|
12
|
+
return os.path.join(BASE, name)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def p14():
|
|
16
|
+
# If your files are real Excel files, change read_csv to read_excel
|
|
17
|
+
math = pd.read_csv(path("students_math.csv"))
|
|
18
|
+
science = pd.read_csv(path("student_science.csv"))
|
|
19
|
+
|
|
20
|
+
print("Math Dataset:")
|
|
21
|
+
print(math)
|
|
22
|
+
print("\nScience Dataset:")
|
|
23
|
+
print(science)
|
|
24
|
+
|
|
25
|
+
data = pd.merge(math, science, on="Student_ID")
|
|
26
|
+
print("\nMerged Dataset:")
|
|
27
|
+
print(data)
|
|
28
|
+
|
|
29
|
+
correlation = data["Math"].corr(data["Science"])
|
|
30
|
+
print("\nCorrelation between Math and Science =", round(correlation, 2))
|
|
31
|
+
|
|
32
|
+
print("\nCorrelation Matrix:")
|
|
33
|
+
print(data[["Math", "Science"]].corr())
|
|
34
|
+
|
|
35
|
+
plt.scatter(data["Math"], data["Science"])
|
|
36
|
+
plt.xlabel("Math Marks")
|
|
37
|
+
plt.ylabel("Science Marks")
|
|
38
|
+
plt.title("Correlation between Math and Science Marks")
|
|
39
|
+
plt.show()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
p14()
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
+
except NameError:
|
|
8
|
+
BASE = os.getcwd()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def path(name):
|
|
12
|
+
return os.path.join(BASE, name)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def p4():
|
|
16
|
+
# Histogram
|
|
17
|
+
y = [10, 5, 8, 4, 2]
|
|
18
|
+
plt.hist(y)
|
|
19
|
+
plt.title("Histogram")
|
|
20
|
+
plt.show()
|
|
21
|
+
|
|
22
|
+
# Pie chart (simple)
|
|
23
|
+
y = np.array([35, 25, 25, 15])
|
|
24
|
+
plt.pie(y)
|
|
25
|
+
plt.title("Pie Chart")
|
|
26
|
+
plt.show()
|
|
27
|
+
|
|
28
|
+
# Pie chart (labels, explode, shadow)
|
|
29
|
+
labels = ["apple", "banana", "cherry", "durian", "elderberries", "figs", "grapes"]
|
|
30
|
+
sizes = [32, 20, 15, 10, 10, 8, 5]
|
|
31
|
+
p = plt.pie(sizes, labels=labels, explode=(0.07, 0, 0, 0, 0, 0, 0),
|
|
32
|
+
autopct="%1.1f%%", startangle=130, shadow=True)
|
|
33
|
+
plt.axis("equal")
|
|
34
|
+
for text in p[1]:
|
|
35
|
+
text.set_fontsize(12)
|
|
36
|
+
plt.show()
|
|
37
|
+
|
|
38
|
+
# Line chart with grid
|
|
39
|
+
x = np.array([80, 85, 90, 95, 100, 105, 110, 115, 120, 125])
|
|
40
|
+
y = np.array([240, 250, 260, 270, 280, 290, 300, 310, 320, 330])
|
|
41
|
+
plt.title("Sports Watch Data")
|
|
42
|
+
plt.xlabel("Average Pulse")
|
|
43
|
+
plt.ylabel("Calorie Burnage")
|
|
44
|
+
plt.plot(x, y)
|
|
45
|
+
plt.grid()
|
|
46
|
+
plt.show()
|
|
47
|
+
|
|
48
|
+
# Stairs
|
|
49
|
+
y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0]
|
|
50
|
+
fig, ax = plt.subplots()
|
|
51
|
+
ax.stairs(y, linewidth=2.5)
|
|
52
|
+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
|
|
53
|
+
ylim=(0, 8), yticks=np.arange(1, 8))
|
|
54
|
+
plt.show()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
p4()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
except NameError:
|
|
7
|
+
BASE = os.getcwd()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def path(name):
|
|
11
|
+
return os.path.join(BASE, name)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def p10(image_name="1.png"):
|
|
15
|
+
from PIL import Image
|
|
16
|
+
|
|
17
|
+
imageIn = Image.open(path(image_name))
|
|
18
|
+
fig1 = plt.figure(figsize=(8, 8))
|
|
19
|
+
fig1.suptitle("Audi R8", fontsize=20)
|
|
20
|
+
plt.imshow(imageIn)
|
|
21
|
+
plt.show()
|
|
22
|
+
|
|
23
|
+
mask = imageIn.convert("L")
|
|
24
|
+
th = 49
|
|
25
|
+
imageOut = mask.point(lambda i: i < th and 255)
|
|
26
|
+
imageOut.save(path("audi.png"))
|
|
27
|
+
|
|
28
|
+
imageTest = Image.open(path("audi.png"))
|
|
29
|
+
fig2 = plt.figure(figsize=(8, 8))
|
|
30
|
+
fig2.suptitle("Audi R8 Edge", fontsize=20)
|
|
31
|
+
plt.imshow(imageTest, cmap="gray")
|
|
32
|
+
plt.show()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
p10()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
5
|
+
except NameError:
|
|
6
|
+
BASE = os.getcwd()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def path(name):
|
|
10
|
+
return os.path.join(BASE, name)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def p2a():
|
|
14
|
+
baddata = " Data Science with too many spaces is great. "
|
|
15
|
+
print(">", baddata, "<")
|
|
16
|
+
cleandata = " ".join(baddata.split())
|
|
17
|
+
print(">", cleandata, "<")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
p2a()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
except NameError:
|
|
7
|
+
BASE = os.getcwd()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def path(name):
|
|
11
|
+
return os.path.join(BASE, name)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load_ip_data():
|
|
15
|
+
df = pd.read_csv(path("IP_DATA_ALL.csv"), header=0, low_memory=False,
|
|
16
|
+
encoding="latin-1",
|
|
17
|
+
usecols=["Country", "Place.Name", "Latitude", "Longitude"])
|
|
18
|
+
df.rename(columns={"Place.Name": "Place_Name"}, inplace=True)
|
|
19
|
+
return df
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def p2d():
|
|
23
|
+
IP_DATA_ALL = load_ip_data()
|
|
24
|
+
LondonData = IP_DATA_ALL.loc[IP_DATA_ALL["Place_Name"] == "London"]
|
|
25
|
+
|
|
26
|
+
LondonFree = LondonData[["Country", "Place_Name", "Latitude"]].copy()
|
|
27
|
+
print("Outliers (latitude outside 51.0 to 52.0)")
|
|
28
|
+
LondonOutliers = LondonFree[(LondonFree["Latitude"] < 51.0) |
|
|
29
|
+
(LondonFree["Latitude"] > 52.0)]
|
|
30
|
+
print(LondonOutliers)
|
|
31
|
+
print("Total outliers :", len(LondonOutliers))
|
|
32
|
+
|
|
33
|
+
print("\nNon-outliers (latitude inside 51.0 to 52.0)")
|
|
34
|
+
print(LondonFree[(LondonFree["Latitude"] >= 51.0) &
|
|
35
|
+
(LondonFree["Latitude"] <= 52.0)])
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
p2d()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
+
except NameError:
|
|
9
|
+
BASE = os.getcwd()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def path(name):
|
|
13
|
+
return os.path.join(BASE, name)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def load_ip_data():
|
|
17
|
+
df = pd.read_csv(path("IP_DATA_ALL.csv"), header=0, low_memory=False,
|
|
18
|
+
encoding="latin-1",
|
|
19
|
+
usecols=["Country", "Place.Name", "Latitude", "Longitude"])
|
|
20
|
+
df.rename(columns={"Place.Name": "Place_Name"}, inplace=True)
|
|
21
|
+
return df
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def p2f():
|
|
25
|
+
IP_DATA_ALL = load_ip_data()
|
|
26
|
+
x = IP_DATA_ALL["Latitude"].dropna()
|
|
27
|
+
|
|
28
|
+
mu, sigma = x.mean(), x.std()
|
|
29
|
+
print("Mean:", mu, " Std:", sigma)
|
|
30
|
+
|
|
31
|
+
num_bins = 25
|
|
32
|
+
fig, ax = plt.subplots(figsize=(10, 6))
|
|
33
|
+
n, bins, patches = ax.hist(x, num_bins, density=True, alpha=0.6)
|
|
34
|
+
|
|
35
|
+
# Normal distribution curve (computed with numpy)
|
|
36
|
+
y = (1 / (sigma * np.sqrt(2 * np.pi))) * np.exp(-0.5 * ((bins - mu) / sigma) ** 2)
|
|
37
|
+
ax.plot(bins, y, "--", color="red")
|
|
38
|
+
|
|
39
|
+
ax.set_xlabel("Latitude")
|
|
40
|
+
ax.set_ylabel("Probability density")
|
|
41
|
+
ax.set_title("Histogram of Latitude: mu=%.2f, sigma=%.2f" % (mu, sigma))
|
|
42
|
+
fig.tight_layout()
|
|
43
|
+
plt.show()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
p2f()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
except NameError:
|
|
7
|
+
BASE = os.getcwd()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def path(name):
|
|
11
|
+
return os.path.join(BASE, name)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def p1b():
|
|
15
|
+
InputData = pd.read_csv(path("Country.csv"), encoding="latin-1")
|
|
16
|
+
print("Input Data Values")
|
|
17
|
+
print(InputData)
|
|
18
|
+
print("=" * 60)
|
|
19
|
+
|
|
20
|
+
ProcessData = InputData.copy()
|
|
21
|
+
ProcessData.drop(columns=["ISO-2-CODE", "ISO-3-Code"], inplace=True)
|
|
22
|
+
ProcessData.rename(columns={"Country": "CountryName",
|
|
23
|
+
"ISO-M49": "CountryNumber"}, inplace=True)
|
|
24
|
+
ProcessData.set_index("CountryNumber", inplace=True)
|
|
25
|
+
ProcessData.sort_values(by="CountryName", ascending=True, inplace=True)
|
|
26
|
+
|
|
27
|
+
print("Processed Data")
|
|
28
|
+
print(ProcessData)
|
|
29
|
+
print("=" * 60)
|
|
30
|
+
|
|
31
|
+
ProcessData.to_csv(path("HORUS-CSV-Country.csv"))
|
|
32
|
+
print("CSV to HORUS - Done Successfully")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
p1b()
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
+
except NameError:
|
|
8
|
+
BASE = os.getcwd()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def path(name):
|
|
12
|
+
return os.path.join(BASE, name)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def p7(image_name="hough.jpg"):
|
|
16
|
+
import cv2
|
|
17
|
+
|
|
18
|
+
img = cv2.imread(path(image_name))
|
|
19
|
+
if img is None:
|
|
20
|
+
print("Could not read", image_name, "- put it in the same folder.")
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
plt.figure(figsize=(8, 6))
|
|
24
|
+
plt.title("Original Image")
|
|
25
|
+
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
|
26
|
+
plt.axis("off")
|
|
27
|
+
plt.show()
|
|
28
|
+
|
|
29
|
+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
30
|
+
edges = cv2.Canny(gray, 50, 200)
|
|
31
|
+
|
|
32
|
+
lines = cv2.HoughLinesP(edges, 1, np.pi / 180, 68,
|
|
33
|
+
minLineLength=15, maxLineGap=250)
|
|
34
|
+
|
|
35
|
+
if lines is not None:
|
|
36
|
+
for line in lines:
|
|
37
|
+
x1, y1, x2, y2 = line.flatten()
|
|
38
|
+
cv2.line(img, (x1, y1), (x2, y2), (255, 0, 0), 3)
|
|
39
|
+
else:
|
|
40
|
+
print("No lines detected.")
|
|
41
|
+
|
|
42
|
+
plt.figure(figsize=(8, 6))
|
|
43
|
+
plt.title("Line Detection using Hough Transform")
|
|
44
|
+
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
|
45
|
+
plt.axis("off")
|
|
46
|
+
plt.show()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
p7()
|