numpandaspy 0.3.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.
- numpandaspy-0.3.0/PKG-INFO +5 -0
- numpandaspy-0.3.0/mypackage/__init__.py +1 -0
- numpandaspy-0.3.0/mypackage/__main__.py +3 -0
- numpandaspy-0.3.0/mypackage/cli.py +120 -0
- numpandaspy-0.3.0/mypackage/data/cloud/1.txt +5 -0
- numpandaspy-0.3.0/mypackage/data/cloud/2.txt +34 -0
- numpandaspy-0.3.0/mypackage/data/cloud/4.txt +9 -0
- numpandaspy-0.3.0/mypackage/data/cloud/5.txt +3 -0
- numpandaspy-0.3.0/mypackage/data/cloud/8.txt +5 -0
- numpandaspy-0.3.0/mypackage/data/cloud/_index.txt +5 -0
- numpandaspy-0.3.0/mypackage/data/ds/1.txt +72 -0
- numpandaspy-0.3.0/mypackage/data/ds/2a.txt +20 -0
- numpandaspy-0.3.0/mypackage/data/ds/2b.txt +44 -0
- numpandaspy-0.3.0/mypackage/data/ds/2c.txt +20 -0
- numpandaspy-0.3.0/mypackage/data/ds/2d.txt +24 -0
- numpandaspy-0.3.0/mypackage/data/ds/2e.txt +33 -0
- numpandaspy-0.3.0/mypackage/data/ds/2f.txt +31 -0
- numpandaspy-0.3.0/mypackage/data/ds/2g.txt +46 -0
- numpandaspy-0.3.0/mypackage/data/ds/2h.txt +75 -0
- numpandaspy-0.3.0/mypackage/data/ds/3a.txt +21 -0
- numpandaspy-0.3.0/mypackage/data/ds/3b.txt +22 -0
- numpandaspy-0.3.0/mypackage/data/ds/3c.txt +16 -0
- numpandaspy-0.3.0/mypackage/data/ds/3d.txt +32 -0
- numpandaspy-0.3.0/mypackage/data/ds/3e.txt +56 -0
- numpandaspy-0.3.0/mypackage/data/ds/4a.txt +34 -0
- numpandaspy-0.3.0/mypackage/data/ds/4b.txt +32 -0
- numpandaspy-0.3.0/mypackage/data/ds/4c.txt +22 -0
- numpandaspy-0.3.0/mypackage/data/ds/4d.txt +56 -0
- numpandaspy-0.3.0/mypackage/data/ds/4e.txt +23 -0
- numpandaspy-0.3.0/mypackage/data/ds/4f.txt +29 -0
- numpandaspy-0.3.0/mypackage/data/ds/4g.txt +73 -0
- numpandaspy-0.3.0/mypackage/data/ds/4h.txt +26 -0
- numpandaspy-0.3.0/mypackage/data/ds/4i.txt +91 -0
- numpandaspy-0.3.0/mypackage/data/ds/4j.txt +113 -0
- numpandaspy-0.3.0/mypackage/data/ds/4k.txt +70 -0
- numpandaspy-0.3.0/mypackage/data/ds/4l.txt +31 -0
- numpandaspy-0.3.0/mypackage/data/ds/4m.txt +44 -0
- numpandaspy-0.3.0/mypackage/data/ds/5a.txt +109 -0
- numpandaspy-0.3.0/mypackage/data/ds/5b.txt +86 -0
- numpandaspy-0.3.0/mypackage/data/ds/5c.txt +17 -0
- numpandaspy-0.3.0/mypackage/data/ds/5d.txt +35 -0
- numpandaspy-0.3.0/mypackage/data/ds/5e.txt +85 -0
- numpandaspy-0.3.0/mypackage/data/ds/5f.txt +95 -0
- numpandaspy-0.3.0/mypackage/data/ds/5g.txt +110 -0
- numpandaspy-0.3.0/mypackage/data/ds/5h.txt +114 -0
- numpandaspy-0.3.0/mypackage/data/ds/5i.txt +50 -0
- numpandaspy-0.3.0/mypackage/data/ds/5j.txt +35 -0
- numpandaspy-0.3.0/mypackage/data/ds/5k.txt +269 -0
- numpandaspy-0.3.0/mypackage/data/ds/5l.txt +313 -0
- numpandaspy-0.3.0/mypackage/data/ds/5m.txt +562 -0
- numpandaspy-0.3.0/mypackage/data/ds/5n.txt +97 -0
- numpandaspy-0.3.0/mypackage/data/ds/5o.txt +33 -0
- numpandaspy-0.3.0/mypackage/data/ds/5p.txt +58 -0
- numpandaspy-0.3.0/mypackage/data/ds/5q.txt +143 -0
- numpandaspy-0.3.0/mypackage/data/ds/6a.txt +221 -0
- numpandaspy-0.3.0/mypackage/data/ds/6b.txt +99 -0
- numpandaspy-0.3.0/mypackage/data/ds/6c.txt +155 -0
- numpandaspy-0.3.0/mypackage/data/ds/7a.txt +296 -0
- numpandaspy-0.3.0/mypackage/data/ds/7b.txt +25 -0
- numpandaspy-0.3.0/mypackage/data/ds/8a.txt +58 -0
- numpandaspy-0.3.0/mypackage/data/ds/8b.txt +50 -0
- numpandaspy-0.3.0/mypackage/data/ds/8c.txt +55 -0
- numpandaspy-0.3.0/mypackage/data/ds/8d.txt +63 -0
- numpandaspy-0.3.0/mypackage/data/ds/8e.txt +62 -0
- numpandaspy-0.3.0/mypackage/data/ds/8f.txt +58 -0
- numpandaspy-0.3.0/mypackage/data/ds/8g.txt +61 -0
- numpandaspy-0.3.0/mypackage/data/ds/8h.txt +30 -0
- numpandaspy-0.3.0/mypackage/data/ds/8i.txt +118 -0
- numpandaspy-0.3.0/mypackage/data/ds/9a.txt +61 -0
- numpandaspy-0.3.0/mypackage/data/ds/9b.txt +66 -0
- numpandaspy-0.3.0/mypackage/data/ds/9c.txt +113 -0
- numpandaspy-0.3.0/mypackage/data/ds/_index.txt +60 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/10a.txt +101 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/10b.txt +176 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/1a.txt +6 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/1b.txt +82 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/2a.txt +48 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/2b.txt +77 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/3a.txt +28 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/3b.txt +39 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/4a.txt +89 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/4b.txt +25 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/5a.txt +110 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/5b.txt +50 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/6a.txt +32 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/6b.txt +92 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/6c.txt +32 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/7a.txt +52 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/7b.txt +27 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/8a.txt +49 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/8b.txt +64 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/9a.txt +18 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/9b.txt +31 -0
- numpandaspy-0.3.0/mypackage/data/softcomputing/_index.txt +21 -0
- numpandaspy-0.3.0/mypackage/viewer.py +91 -0
- numpandaspy-0.3.0/numpandaspy.egg-info/PKG-INFO +5 -0
- numpandaspy-0.3.0/numpandaspy.egg-info/SOURCES.txt +100 -0
- numpandaspy-0.3.0/numpandaspy.egg-info/dependency_links.txt +1 -0
- numpandaspy-0.3.0/numpandaspy.egg-info/entry_points.txt +2 -0
- numpandaspy-0.3.0/numpandaspy.egg-info/top_level.txt +1 -0
- numpandaspy-0.3.0/pyproject.toml +18 -0
- numpandaspy-0.3.0/setup.cfg +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.0"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import re
|
|
3
|
+
import shutil
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
DATA_DIR = Path(__file__).parent / "data"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _natural(p):
|
|
11
|
+
return [int(t) if t.isdigit() else t.lower() for t in re.split(r"(\d+)", p.stem)]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _subjects():
|
|
15
|
+
return sorted(d for d in DATA_DIR.iterdir() if d.is_dir())
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _practicals(subject_dir):
|
|
19
|
+
return sorted(
|
|
20
|
+
(f for f in subject_dir.iterdir() if f.is_file() and not f.name.startswith("_")),
|
|
21
|
+
key=_natural,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _titles(subject_dir):
|
|
26
|
+
idx = subject_dir / "_index.txt"
|
|
27
|
+
out = {}
|
|
28
|
+
if idx.exists():
|
|
29
|
+
for line in idx.read_text(encoding="utf-8").splitlines():
|
|
30
|
+
if "\t" in line:
|
|
31
|
+
k, v = line.split("\t", 1)
|
|
32
|
+
out[k.strip().lower()] = v.strip()
|
|
33
|
+
return out
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _simple(s):
|
|
37
|
+
return re.sub(r"[\s_\-]", "", s.lower())
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _find_subject(name):
|
|
41
|
+
n = _simple(name)
|
|
42
|
+
subs = _subjects()
|
|
43
|
+
for d in subs:
|
|
44
|
+
if _simple(d.name) == n:
|
|
45
|
+
return d
|
|
46
|
+
hits = [d for d in subs if _simple(d.name).startswith(n)]
|
|
47
|
+
return hits[0] if len(hits) == 1 else None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _find_practical(subject_dir, name):
|
|
51
|
+
"""Match '1a' or '1a.txt' (any stored extension) against the files."""
|
|
52
|
+
want = name.lower()
|
|
53
|
+
for f in _practicals(subject_dir):
|
|
54
|
+
if f.name.lower() == want or f.stem.lower() == want:
|
|
55
|
+
return f
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _print_list(subject_dir, only=None):
|
|
60
|
+
titles = _titles(subject_dir)
|
|
61
|
+
for f in _practicals(subject_dir):
|
|
62
|
+
if only and not re.fullmatch(re.escape(only.lower()) + r"[a-z]+", f.stem.lower()):
|
|
63
|
+
continue
|
|
64
|
+
print(f" {f.name:<10} {titles.get(f.stem.lower(), '')}")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def main(argv=None):
|
|
68
|
+
parser = argparse.ArgumentParser(
|
|
69
|
+
prog="sk-offline",
|
|
70
|
+
description="List practicals, or save one into the current folder.",
|
|
71
|
+
epilog="examples: sk-offline ds | sk-offline ds 1a.txt",
|
|
72
|
+
)
|
|
73
|
+
parser.add_argument("subject", nargs="?", help="subject name")
|
|
74
|
+
parser.add_argument("practical", nargs="?", help="practical file, e.g. 1a.txt (or just 1a)")
|
|
75
|
+
parser.add_argument("-f", "--force", action="store_true", help="overwrite the file if it already exists")
|
|
76
|
+
parser.add_argument("--view", action="store_true", help="show line by line (Up/Down, q to quit) instead of saving")
|
|
77
|
+
args = parser.parse_args(argv)
|
|
78
|
+
|
|
79
|
+
if not args.subject:
|
|
80
|
+
print("Subjects:", ", ".join(d.name for d in _subjects()))
|
|
81
|
+
print("Usage: sk-offline <subject> [practical] e.g. sk-offline ds 1a.txt")
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
subject_dir = _find_subject(args.subject)
|
|
85
|
+
if subject_dir is None:
|
|
86
|
+
print(f"Unknown subject '{args.subject}'.", file=sys.stderr)
|
|
87
|
+
print("Available:", ", ".join(d.name for d in _subjects()), file=sys.stderr)
|
|
88
|
+
sys.exit(1)
|
|
89
|
+
|
|
90
|
+
if not args.practical:
|
|
91
|
+
print(f"{subject_dir.name} practicals:")
|
|
92
|
+
_print_list(subject_dir)
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
file = _find_practical(subject_dir, args.practical)
|
|
96
|
+
if file is None:
|
|
97
|
+
base = re.sub(r"\.[A-Za-z0-9]+$", "", args.practical)
|
|
98
|
+
parts = [f for f in _practicals(subject_dir) if re.fullmatch(re.escape(base.lower()) + r"[a-z]+", f.stem.lower())]
|
|
99
|
+
if parts:
|
|
100
|
+
print(f"Practical {base} has several parts, pick one:")
|
|
101
|
+
_print_list(subject_dir, only=base)
|
|
102
|
+
return
|
|
103
|
+
print(f"No practical '{args.practical}' in {subject_dir.name}. Available:", file=sys.stderr)
|
|
104
|
+
_print_list(subject_dir)
|
|
105
|
+
sys.exit(1)
|
|
106
|
+
|
|
107
|
+
if args.view:
|
|
108
|
+
if not sys.stdin.isatty():
|
|
109
|
+
print("--view needs an interactive terminal.", file=sys.stderr)
|
|
110
|
+
sys.exit(1)
|
|
111
|
+
from .viewer import show
|
|
112
|
+
show(file.read_text(encoding="utf-8").splitlines())
|
|
113
|
+
return
|
|
114
|
+
|
|
115
|
+
dest = Path.cwd() / file.name
|
|
116
|
+
if dest.exists() and not args.force:
|
|
117
|
+
print(f"{dest.name} already exists in this folder. Use --force to overwrite it.", file=sys.stderr)
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
shutil.copyfile(file, dest) # byte-for-byte copy, keeps line endings as stored
|
|
120
|
+
print(f"Saved {dest}")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<ServiceConfiguration serviceName="HelloCloud"
|
|
3
|
+
xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
|
|
4
|
+
<Role name="WebRole1">
|
|
5
|
+
<Instances count="1" />
|
|
6
|
+
<ConfigurationSettings />
|
|
7
|
+
</Role>
|
|
8
|
+
</ServiceConfiguration>
|
|
9
|
+
|
|
10
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
11
|
+
<ServiceDefinition name="HelloCloud"
|
|
12
|
+
xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
|
|
13
|
+
<WebRole name="WebRole1" enableNativeCodeExecution="false">
|
|
14
|
+
<InputEndpoints>
|
|
15
|
+
<InputEndpoint name="HttpIn" protocol="http" port="80" />
|
|
16
|
+
</InputEndpoints>
|
|
17
|
+
<ConfigurationSettings />
|
|
18
|
+
</WebRole>
|
|
19
|
+
</ServiceDefinition>
|
|
20
|
+
|
|
21
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
22
|
+
<head runat="server">
|
|
23
|
+
<title>Hello Windows Azure</title>
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<form id="form1" runat="server">
|
|
27
|
+
<div>
|
|
28
|
+
<h1>Hello From The Cloud!</h1>
|
|
29
|
+
</div>
|
|
30
|
+
</form>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
|
33
|
+
|
|
34
|
+
<Instances count="4" />
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
1 Windows/Linux failover cluster (PowerShell)
|
|
2
|
+
2 Windows Azure: Hello Cloud application (config + Default.aspx)
|
|
3
|
+
4 Hadoop (HDP 2.0 for Windows): install, start services, smoke test
|
|
4
|
+
5 Google App Engine: deploy from command line
|
|
5
|
+
8 OpenNebula sandbox: unpack image, instantiate template
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
PRACTICAL 1: CREATING A DATA MODEL IN CASSANDRA
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
1. Create Keyspace
|
|
5
|
+
CREATE KEYSPACE UDIT
|
|
6
|
+
WITH replication = {
|
|
7
|
+
'class': 'SimpleStrategy',
|
|
8
|
+
'replication_factor': 3
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
2. Display Available Keyspaces
|
|
12
|
+
DESCRIBE keyspaces;
|
|
13
|
+
|
|
14
|
+
3. Select Keyspace
|
|
15
|
+
USE tutorialspoint;
|
|
16
|
+
|
|
17
|
+
4. Create Table
|
|
18
|
+
CREATE TABLE emp20 (
|
|
19
|
+
emp_id int PRIMARY KEY,
|
|
20
|
+
emp_name text,
|
|
21
|
+
emp_city text,
|
|
22
|
+
emp_sal varint,
|
|
23
|
+
emp_phone varint
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
5. Display Table Records
|
|
27
|
+
SELECT * FROM emp20;
|
|
28
|
+
|
|
29
|
+
6. Insert First Record
|
|
30
|
+
INSERT INTO emp20 (
|
|
31
|
+
emp_id, emp_city, emp_name, emp_phone, emp_sal
|
|
32
|
+
)
|
|
33
|
+
VALUES (
|
|
34
|
+
1, 'Thane', 'Nikhil', 9967753517, 30000
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
7. Insert Second Record
|
|
38
|
+
INSERT INTO emp20 (
|
|
39
|
+
emp_id, emp_city, emp_name, emp_phone, emp_sal
|
|
40
|
+
)
|
|
41
|
+
VALUES (
|
|
42
|
+
3, 'Shraddha', 'Santacruz', 9888888887, 39000
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
8. Display Inserted Records
|
|
46
|
+
SELECT * FROM emp20;
|
|
47
|
+
|
|
48
|
+
9. Create Index
|
|
49
|
+
CREATE INDEX NAME ON emp20 (emp_name);
|
|
50
|
+
|
|
51
|
+
10. Execute Batch Operations
|
|
52
|
+
BEGIN BATCH
|
|
53
|
+
|
|
54
|
+
INSERT INTO emp20 (
|
|
55
|
+
emp_id, emp_city, emp_name, emp_phone, emp_sal
|
|
56
|
+
)
|
|
57
|
+
VALUES (
|
|
58
|
+
4, 'Pune', 'rajeev', 9848022331, 30000
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
UPDATE emp20
|
|
62
|
+
SET emp_sal = 40000
|
|
63
|
+
WHERE emp_id = 2;
|
|
64
|
+
|
|
65
|
+
DELETE emp_city
|
|
66
|
+
FROM emp20
|
|
67
|
+
WHERE emp_id = 3;
|
|
68
|
+
|
|
69
|
+
APPLY BATCH;
|
|
70
|
+
|
|
71
|
+
11. Display Final Records
|
|
72
|
+
SELECT * FROM emp20;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/Country_Code.csv'
|
|
3
|
+
InputData=pd.read_csv(sInputFileName,encoding="latin-1")
|
|
4
|
+
print('Input Data Values ===================================')
|
|
5
|
+
print(InputData)
|
|
6
|
+
print('=====================================================')
|
|
7
|
+
ProcessData=InputData
|
|
8
|
+
print(ProcessData)
|
|
9
|
+
ProcessData.drop('ISO-2-CODE', axis=1,inplace=True)
|
|
10
|
+
ProcessData.drop('ISO-3-Code', axis=1,inplace=True)
|
|
11
|
+
print(ProcessData)
|
|
12
|
+
ProcessData.rename(columns={'Country': 'CountryName'}, inplace=True)
|
|
13
|
+
ProcessData.rename(columns={'ISO-M49': 'CountryNumber'}, inplace=True)
|
|
14
|
+
print(ProcessData)
|
|
15
|
+
ProcessData.set_index('CountryNumber', inplace=True)
|
|
16
|
+
ProcessData.sort_values('CountryName', axis=0, ascending=True, inplace=True)
|
|
17
|
+
print(ProcessData)
|
|
18
|
+
OutputData=ProcessData
|
|
19
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-CSV-Country1.csv'
|
|
20
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import xml.etree.ElementTree as ET
|
|
3
|
+
def df2xml(data):
|
|
4
|
+
header = data.columns
|
|
5
|
+
root = ET.Element('root')
|
|
6
|
+
for row in range(data.shape[0]):
|
|
7
|
+
entry = ET.SubElement(root,'entry')
|
|
8
|
+
for index in range(data.shape[1]):
|
|
9
|
+
schild=str(header[index])
|
|
10
|
+
child = ET.SubElement(entry, schild)
|
|
11
|
+
if str(data[schild][row]) != 'nan':
|
|
12
|
+
child.text = str(data[schild][row])
|
|
13
|
+
else:
|
|
14
|
+
child.text = 'n/a'
|
|
15
|
+
entry.append(child)
|
|
16
|
+
result = ET.tostring(root)
|
|
17
|
+
return result
|
|
18
|
+
|
|
19
|
+
def xml2df(xml_data):
|
|
20
|
+
root = ET.XML(xml_data)
|
|
21
|
+
all_records = []
|
|
22
|
+
for i, child in enumerate(root):
|
|
23
|
+
record = {}
|
|
24
|
+
for subchild in child:
|
|
25
|
+
record[subchild.tag] = subchild.text
|
|
26
|
+
all_records.append(record)
|
|
27
|
+
return pd.DataFrame(all_records)
|
|
28
|
+
|
|
29
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/Country_Code.xml'
|
|
30
|
+
InputData = open(sInputFileName).read()
|
|
31
|
+
ProcessDataXML=InputData
|
|
32
|
+
ProcessData=xml2df(ProcessDataXML)
|
|
33
|
+
print(ProcessData)
|
|
34
|
+
ProcessData.drop('ISO-2-CODE', axis=1,inplace=True)
|
|
35
|
+
ProcessData.drop('ISO-3-Code', axis=1,inplace=True)
|
|
36
|
+
ProcessData.rename(columns={'Country': 'CountryName'}, inplace=True)
|
|
37
|
+
ProcessData.rename(columns={'ISO-M49': 'CountryNumber'}, inplace=True)
|
|
38
|
+
print(ProcessData)
|
|
39
|
+
ProcessData.set_index('CountryNumber', inplace=True)
|
|
40
|
+
ProcessData.sort_values('CountryName', axis=0, ascending=False, inplace=True)
|
|
41
|
+
print(ProcessData)
|
|
42
|
+
OutputData=ProcessData
|
|
43
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-XML-Country.csv'
|
|
44
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/Country_Code.json'
|
|
3
|
+
InputData=pd.read_json(sInputFileName, orient='index', encoding="latin-1")
|
|
4
|
+
print('Input Data Values ===================================')
|
|
5
|
+
print(InputData)
|
|
6
|
+
print('=====================================================')
|
|
7
|
+
ProcessData=InputData
|
|
8
|
+
ProcessData.drop('ISO-2-CODE', axis=1,inplace=True)
|
|
9
|
+
ProcessData.drop('ISO-3-Code', axis=1,inplace=True)
|
|
10
|
+
ProcessData.rename(columns={'Country': 'CountryName'}, inplace=True)
|
|
11
|
+
ProcessData.rename(columns={'ISO-M49': 'CountryNumber'}, inplace=True)
|
|
12
|
+
ProcessData.set_index('CountryNumber', inplace=True)
|
|
13
|
+
ProcessData.sort_values('CountryName', axis=0, ascending=False, inplace=True)
|
|
14
|
+
print('Process Data Values =================================')
|
|
15
|
+
print(ProcessData)
|
|
16
|
+
print('=====================================================')
|
|
17
|
+
OutputData=ProcessData
|
|
18
|
+
sOutputFileName='c:/VKHCG/05-DS/9999-Data/HORUS-JSON-Country.csv'
|
|
19
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
20
|
+
print('JSON to HORUS - Done'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import sqlite3 as sq
|
|
3
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/utility.db'
|
|
4
|
+
sInputTable='Country_Code'
|
|
5
|
+
conn = sq.connect(sInputFileName)
|
|
6
|
+
sSQL='select * FROM ' + sInputTable + ';'
|
|
7
|
+
InputData=pd.read_sql_query(sSQL, conn)
|
|
8
|
+
print('Input Data Values ===================================')
|
|
9
|
+
print(InputData)
|
|
10
|
+
print('=====================================================')
|
|
11
|
+
ProcessData=InputData
|
|
12
|
+
ProcessData.drop('ISO-2-CODE', axis=1,inplace=True)
|
|
13
|
+
ProcessData.drop('ISO-3-Code', axis=1,inplace=True)
|
|
14
|
+
ProcessData.rename(columns={'Country': 'CountryName'}, inplace=True)
|
|
15
|
+
ProcessData.rename(columns={'ISO-M49': 'CountryNumber'}, inplace=True)
|
|
16
|
+
ProcessData.set_index('CountryNumber', inplace=True)
|
|
17
|
+
ProcessData.sort_values('CountryName', axis=0, ascending=False, inplace=True)
|
|
18
|
+
print('Process Data Values =================================')
|
|
19
|
+
print(ProcessData)
|
|
20
|
+
print('=====================================================')
|
|
21
|
+
OutputData=ProcessData
|
|
22
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-CSV-Country.csv'
|
|
23
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
24
|
+
print('Database to HORUS - Done')
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from scipy.misc import imread
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
5
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/Angus.jpg'
|
|
6
|
+
InputData = imread(sInputFileName, flatten=False, mode='RGBA')
|
|
7
|
+
print('Input Data Values ===================================')
|
|
8
|
+
print('X: ',InputData.shape[0])
|
|
9
|
+
print('Y: ',InputData.shape[1])
|
|
10
|
+
print('RGBA: ', InputData.shape[2])
|
|
11
|
+
print('=====================================================')
|
|
12
|
+
ProcessRawData=InputData.flatten()
|
|
13
|
+
y=InputData.shape[2] + 2
|
|
14
|
+
x=int(ProcessRawData.shape[0]/y)
|
|
15
|
+
ProcessData=pd.DataFrame(np.reshape(ProcessRawData, (x, y)))
|
|
16
|
+
sColumns= ['XAxis','YAxis','Red', 'Green', 'Blue','Alpha']
|
|
17
|
+
ProcessData.columns=sColumns
|
|
18
|
+
ProcessData.index.names =['ID']
|
|
19
|
+
print('Rows: ',ProcessData.shape[0])
|
|
20
|
+
print('Columns :',ProcessData.shape[1])
|
|
21
|
+
print('=====================================================')
|
|
22
|
+
print('Process Data Values =================================')
|
|
23
|
+
print('=====================================================')
|
|
24
|
+
plt.imshow(InputData)
|
|
25
|
+
plt.show()
|
|
26
|
+
print('=====================================================')
|
|
27
|
+
OutputData=ProcessData
|
|
28
|
+
print('Storing File')
|
|
29
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-Picture.csv'
|
|
30
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
31
|
+
print('=====================================================')
|
|
32
|
+
print('Picture to HORUS - Done')
|
|
33
|
+
print('=====================================================')
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
import cv2
|
|
4
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/dog.mp4'
|
|
5
|
+
sDataBaseDir='C:/VKHCG/05-DS/9999-Data/temp'
|
|
6
|
+
if os.path.exists(sDataBaseDir):
|
|
7
|
+
shutil.rmtree(sDataBaseDir)
|
|
8
|
+
if not os.path.exists(sDataBaseDir):
|
|
9
|
+
os.makedirs(sDataBaseDir)
|
|
10
|
+
print('=====================================================')
|
|
11
|
+
print('Start Movie to Frames')
|
|
12
|
+
print('=====================================================')
|
|
13
|
+
vidcap = cv2.VideoCapture(sInputFileName)
|
|
14
|
+
success,image = vidcap.read()
|
|
15
|
+
count = 0
|
|
16
|
+
while success:
|
|
17
|
+
success,image = vidcap.read()
|
|
18
|
+
sFrame=sDataBaseDir + str('/dog-frame-' + str(format(count, '04d'))+ '.jpg')
|
|
19
|
+
print('Extracted: ', sFrame)
|
|
20
|
+
cv2.imwrite(sFrame, image)
|
|
21
|
+
if os.path.getsize(sFrame) == 0:
|
|
22
|
+
count += -1
|
|
23
|
+
os.remove(sFrame)
|
|
24
|
+
print('Removed: ', sFrame)
|
|
25
|
+
if cv2.waitKey(10) == 27:
|
|
26
|
+
break
|
|
27
|
+
count += 1
|
|
28
|
+
print('=====================================================')
|
|
29
|
+
print('Generated : ', count, ' Frames')
|
|
30
|
+
print('=====================================================')
|
|
31
|
+
print('Movie to Frames HORUS - Done')
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from scipy.misc import imread
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
5
|
+
import os
|
|
6
|
+
sDataBaseDir='C:/VKHCG/05-DS/9999-Data/temp'
|
|
7
|
+
f=0
|
|
8
|
+
for file in os.listdir(sDataBaseDir):
|
|
9
|
+
if file.endswith(".jpg"):
|
|
10
|
+
f += 1
|
|
11
|
+
sInputFileName=os.path.join(sDataBaseDir, file)
|
|
12
|
+
print('Process : ', sInputFileName)
|
|
13
|
+
InputData = imread(sInputFileName, flatten=False, mode='RGBA')
|
|
14
|
+
print('Input Data Values ===================================')
|
|
15
|
+
print('X: ',InputData.shape[0])
|
|
16
|
+
print('Y: ',InputData.shape[1])
|
|
17
|
+
print('RGBA: ', InputData.shape[2])
|
|
18
|
+
print('=====================================================')
|
|
19
|
+
ProcessRawData=InputData.flatten()
|
|
20
|
+
y=InputData.shape[2] + 2
|
|
21
|
+
x=int(ProcessRawData.shape[0]/y)
|
|
22
|
+
ProcessFrameData=pd.DataFrame(np.reshape(ProcessRawData, (x, y)))
|
|
23
|
+
ProcessFrameData['Frame']=file
|
|
24
|
+
print('=====================================================')
|
|
25
|
+
print('Process Data Values =================================')
|
|
26
|
+
print('=====================================================')
|
|
27
|
+
plt.imshow(InputData)
|
|
28
|
+
plt.show()
|
|
29
|
+
if f == 1:
|
|
30
|
+
ProcessData=ProcessFrameData
|
|
31
|
+
else:
|
|
32
|
+
ProcessData=ProcessData.append(ProcessFrameData)
|
|
33
|
+
if f > 0:
|
|
34
|
+
sColumns= ['XAxis','YAxis','Red', 'Green', 'Blue','Alpha','FrameName']
|
|
35
|
+
ProcessData.columns=sColumns
|
|
36
|
+
print('=====================================================')
|
|
37
|
+
ProcessFrameData.index.names =['ID']
|
|
38
|
+
print('Rows: ',ProcessData.shape[0])
|
|
39
|
+
print('Columns :',ProcessData.shape[1])
|
|
40
|
+
print('=====================================================')
|
|
41
|
+
OutputData=ProcessData
|
|
42
|
+
print('Storing File')
|
|
43
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-Movie-Frame.csv'
|
|
44
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
45
|
+
print('=====================================================')
|
|
46
|
+
print('Processed ; ', f,' frames')
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from scipy.io import wavfile
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
5
|
+
def show_info(aname, a,r):
|
|
6
|
+
print ('----------------')
|
|
7
|
+
print ("Audio:", aname)
|
|
8
|
+
print ('----------------')
|
|
9
|
+
print ("Rate:", r)
|
|
10
|
+
print ('----------------')
|
|
11
|
+
print ("shape:", a.shape)
|
|
12
|
+
print ("dtype:", a.dtype)
|
|
13
|
+
print ("min, max:", a.min(), a.max())
|
|
14
|
+
print ('----------------')
|
|
15
|
+
plot_info(aname, a,r)
|
|
16
|
+
def plot_info(aname, a,r):
|
|
17
|
+
sTitle= 'Signal Wave - '+ aname + ' at ' + str(r) + 'hz'
|
|
18
|
+
plt.title(sTitle)
|
|
19
|
+
sLegend=[]
|
|
20
|
+
for c in range(a.shape[1]):
|
|
21
|
+
sLabel = 'Ch' + str(c+1)
|
|
22
|
+
sLegend=sLegend+[str(c+1)]
|
|
23
|
+
plt.plot(a[:,c], label=sLabel)
|
|
24
|
+
plt.legend(sLegend)
|
|
25
|
+
plt.show()
|
|
26
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/2ch-sound.wav'
|
|
27
|
+
print('=====================================================')
|
|
28
|
+
print('Processing : ', sInputFileName)
|
|
29
|
+
print('=====================================================')
|
|
30
|
+
InputRate, InputData = wavfile.read(sInputFileName)
|
|
31
|
+
show_info("2 channel", InputData,InputRate)
|
|
32
|
+
ProcessData=pd.DataFrame(InputData)
|
|
33
|
+
sColumns= ['Ch1','Ch2']
|
|
34
|
+
ProcessData.columns=sColumns
|
|
35
|
+
OutputData=ProcessData
|
|
36
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-Audio-2ch.csv'
|
|
37
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
38
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/4ch-sound.wav'
|
|
39
|
+
print('=====================================================')
|
|
40
|
+
print('Processing : ', sInputFileName)
|
|
41
|
+
print('=====================================================')
|
|
42
|
+
InputRate, InputData = wavfile.read(sInputFileName)
|
|
43
|
+
show_info("4 channel", InputData,InputRate)
|
|
44
|
+
ProcessData=pd.DataFrame(InputData)
|
|
45
|
+
sColumns= ['Ch1','Ch2','Ch3', 'Ch4']
|
|
46
|
+
ProcessData.columns=sColumns
|
|
47
|
+
OutputData=ProcessData
|
|
48
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-Audio-4ch.csv'
|
|
49
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
50
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/6ch-sound.wav'
|
|
51
|
+
print('=====================================================')
|
|
52
|
+
print('Processing : ', sInputFileName)
|
|
53
|
+
print('=====================================================')
|
|
54
|
+
InputRate, InputData = wavfile.read(sInputFileName)
|
|
55
|
+
show_info("6 channel", InputData,InputRate)
|
|
56
|
+
ProcessData=pd.DataFrame(InputData)
|
|
57
|
+
sColumns= ['Ch1','Ch2','Ch3', 'Ch4', 'Ch5','Ch6']
|
|
58
|
+
ProcessData.columns=sColumns
|
|
59
|
+
OutputData=ProcessData
|
|
60
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-Audio-6ch.csv'
|
|
61
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
62
|
+
sInputFileName='C:/VKHCG/05-DS/9999-Data/8ch-sound.wav'
|
|
63
|
+
print('=====================================================')
|
|
64
|
+
print('Processing : ', sInputFileName)
|
|
65
|
+
print('=====================================================')
|
|
66
|
+
InputRate, InputData = wavfile.read(sInputFileName)
|
|
67
|
+
show_info("8 channel", InputData,InputRate)
|
|
68
|
+
ProcessData=pd.DataFrame(InputData)
|
|
69
|
+
sColumns= ['Ch1','Ch2','Ch3', 'Ch4', 'Ch5','Ch6','Ch7','Ch8']
|
|
70
|
+
ProcessData.columns=sColumns
|
|
71
|
+
OutputData=ProcessData
|
|
72
|
+
sOutputFileName='C:/VKHCG/05-DS/9999-Data/HORUS-Audio-8ch.csv'
|
|
73
|
+
OutputData.to_csv(sOutputFileName, index = False)
|
|
74
|
+
print('=====================================================')
|
|
75
|
+
print('Audio to HORUS - Done')
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import string
|
|
2
|
+
import datetime as dt
|
|
3
|
+
print('#1 Removing leading or lagging spaces from a data entry');
|
|
4
|
+
baddata = " Data Science with too many spaces is bad!!! "
|
|
5
|
+
print('>',baddata,'<')
|
|
6
|
+
cleandata=baddata.strip()
|
|
7
|
+
print('>',cleandata,'<')
|
|
8
|
+
print('#2 Removing nonprintable characters from a data entry')
|
|
9
|
+
printable = set(string.printable)
|
|
10
|
+
baddata = "Data\x00Science with\x02 funny characters is \x10bad!!!"
|
|
11
|
+
cleandata=' '.join(filter(lambda x: x in string.printable,baddata))
|
|
12
|
+
print('Bad Data : ',baddata);
|
|
13
|
+
print('Clean Data : ',cleandata)
|
|
14
|
+
|
|
15
|
+
print('# 3 Reformatting data entry to match specific formatting criteria.')
|
|
16
|
+
baddate = dt.date(2019, 10, 31)
|
|
17
|
+
baddata=format(baddate,'%Y-%m-%d')
|
|
18
|
+
gooddate = dt.datetime.strptime(baddata,'%Y-%m-%d')
|
|
19
|
+
gooddata=format(gooddate,'%d %B %Y')
|
|
20
|
+
print('Bad Data : ',baddata)
|
|
21
|
+
print('Good Data : ',gooddata)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import matplotlib.mlab as mlab
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import scipy.stats as stats
|
|
5
|
+
np.random.seed(0)
|
|
6
|
+
mu = 90
|
|
7
|
+
sigma = 25
|
|
8
|
+
x = mu + sigma * np.random.randn(5000)
|
|
9
|
+
num_bins = 25
|
|
10
|
+
fig, ax = plt.subplots()
|
|
11
|
+
n, bins, patches = ax.hist(x, num_bins, density=1)
|
|
12
|
+
y = stats.norm.pdf(bins, mu, sigma)
|
|
13
|
+
ax.plot(bins, y, '--')
|
|
14
|
+
ax.set_xlabel('Example Data')
|
|
15
|
+
ax.set_ylabel('Probability density')
|
|
16
|
+
sTitle=r'Histogram ' + str(len(x)) + ' entries into ' + str(num_bins) + ' Bins: $\mu=' + str(mu) + '$, $\sigma=' +
|
|
17
|
+
str(sigma) + '$'
|
|
18
|
+
ax.set_title(sTitle)
|
|
19
|
+
fig.tight_layout()
|
|
20
|
+
sPathFig='C:/VKHCG/05-DS/4000-UL/0200-DU/DU-Histogram.png'
|
|
21
|
+
fig.savefig(sPathFig)
|
|
22
|
+
plt.show()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
InputFileName='IP_DATA_CORE.csv'
|
|
4
|
+
OutputFileName='Retrieve_Router_Location.csv'
|
|
5
|
+
Base='C:/VKHCG'
|
|
6
|
+
print('################################')
|
|
7
|
+
print('Working Base :',Base, ' using ')
|
|
8
|
+
print('################################')
|
|
9
|
+
sFileName=Base + '/01-Vermeulen/00-RawData/' + InputFileName
|
|
10
|
+
print('Loading :',sFileName)
|
|
11
|
+
IP_DATA_ALL=pd.read_csv(sFileName,header=0,low_memory=False, usecols=['Country','Place Name','Latitude','Longitude'], encoding="latin-1")
|
|
12
|
+
IP_DATA_ALL.rename(columns={'Place Name': 'Place_Name'}, inplace=True)
|
|
13
|
+
AllData=IP_DATA_ALL[['Country', 'Place_Name','Latitude']]
|
|
14
|
+
print(AllData)
|
|
15
|
+
MeanData=AllData.groupby(['Country', 'Place_Name'])['Latitude'].mean()
|
|
16
|
+
print(MeanData)
|