Duplicate from Ahmadt/first
Browse filesCo-authored-by: Sohrabi <[email protected]>
- .gitattributes +35 -0
- README.md +12 -0
- index.html +132 -0
- style.css +28 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: First
|
3 |
+
emoji: ⚡
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: blue
|
6 |
+
sdk: static
|
7 |
+
pinned: false
|
8 |
+
license: mit
|
9 |
+
duplicated_from: Ahmadt/first
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title id="header-title"></title>
|
5 |
+
<meta charset="utf-8" />
|
6 |
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
7 |
+
<link rel="icon" type="image/png" href="./favicon.png" />
|
8 |
+
<link
|
9 |
+
rel="stylesheet"
|
10 |
+
href="https://pyscript.net/latest/pyscript.css"
|
11 |
+
/>
|
12 |
+
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
|
13 |
+
|
14 |
+
<link rel="stylesheet" href="./assets/css/examples.css" />
|
15 |
+
</head>
|
16 |
+
|
17 |
+
<body>
|
18 |
+
<nav class="navbar" style="background-color: #000000">
|
19 |
+
<div class="app-header">
|
20 |
+
<a href="/">
|
21 |
+
<img src="./logo.png" class="logo" />
|
22 |
+
</a>
|
23 |
+
<a
|
24 |
+
class="title"
|
25 |
+
id="page-title"
|
26 |
+
href=""
|
27 |
+
style="color: #f0ab3c"
|
28 |
+
></a>
|
29 |
+
</div>
|
30 |
+
</nav>
|
31 |
+
|
32 |
+
<br />
|
33 |
+
<div id="page-message"></div>
|
34 |
+
|
35 |
+
<div id="pandas-source">
|
36 |
+
<h3>Data Source</h3>
|
37 |
+
<input type="text" id="txt-url" class="py-input" size="70" />
|
38 |
+
<button
|
39 |
+
type="submit"
|
40 |
+
id="btn-load"
|
41 |
+
class="py-button"
|
42 |
+
py-click="loadFromURL()"
|
43 |
+
>
|
44 |
+
Load CSV
|
45 |
+
</button>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<div id="pandas-repl" hidden>
|
49 |
+
<h3>Python REPL</h3>
|
50 |
+
<py-repl id="pandas-repl-inner" output="pandas-output-inner">
|
51 |
+
# Hit SHIFT + ENTER to execute example code # Get all closed
|
52 |
+
airports in Great Britain df2 = df.query("type == 'closed' &
|
53 |
+
iso_country == 'GB'") df2
|
54 |
+
</py-repl>
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<div id="pandas-output" hidden>
|
58 |
+
<h3>Output</h3>
|
59 |
+
<div id="pandas-output-inner"></div>
|
60 |
+
</div>
|
61 |
+
|
62 |
+
<div id="pandas-dev-console" hidden>
|
63 |
+
<h3>Dev Console</h3>
|
64 |
+
<py-terminal auto></py-terminal>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<py-tutor>
|
68 |
+
<py-config>
|
69 |
+
plugins = [
|
70 |
+
"https://pyscript.net/latest/plugins/python/py_tutor.py"
|
71 |
+
]
|
72 |
+
packages = ["pandas"]
|
73 |
+
</py-config>
|
74 |
+
|
75 |
+
<section class="pyscript">
|
76 |
+
<py-script>
|
77 |
+
import pandas as pd
|
78 |
+
from pyodide.http import open_url
|
79 |
+
import sys
|
80 |
+
|
81 |
+
title = "Pandas (and basic DOM manipulation)"
|
82 |
+
page_message = "This example loads a remote CSV file into a Pandas dataframe, displays it and lets you manipulate it through a Python REPL"
|
83 |
+
|
84 |
+
url = "https://raw.githubusercontent.com/datasets/airport-codes/master/data/airport-codes.csv"
|
85 |
+
|
86 |
+
Element("header-title").element.innerText = title
|
87 |
+
Element("page-title").element.innerText = title
|
88 |
+
Element("page-message").element.innerText = page_message
|
89 |
+
|
90 |
+
Element("txt-url").element.value = url
|
91 |
+
|
92 |
+
# Depending on the type of DOM element, there are several alternative methods to write to it
|
93 |
+
# Element("id-of-dom-element").write("example")
|
94 |
+
# Element("id-of-dom-element").innerText = "example"
|
95 |
+
# Element("id-of-dom-element").value = "example"
|
96 |
+
# Element("id-of-dom-element").element.innerText = "example"
|
97 |
+
# Element("id-of-dom-element").element.value = "example"
|
98 |
+
# js.document.getElementById("id-of-dom-element").innerText = "example"
|
99 |
+
# js.document.getElementById("id-of-dom-element").value = "example"
|
100 |
+
|
101 |
+
df = pd.DataFrame()
|
102 |
+
|
103 |
+
|
104 |
+
def loadFromURL(*args, **kws):
|
105 |
+
global df
|
106 |
+
|
107 |
+
# clear dataframe & output
|
108 |
+
df = pd.DataFrame()
|
109 |
+
Element("pandas-output-inner").element.innerHTML = ""
|
110 |
+
|
111 |
+
url = Element("txt-url").element.value
|
112 |
+
log ("Trying to fetch CSV from " + url)
|
113 |
+
|
114 |
+
df = pd.read_csv(open_url(url))
|
115 |
+
|
116 |
+
Element("pandas-repl").element.style.display = "block"
|
117 |
+
Element("pandas-output").element.style.display = "block"
|
118 |
+
Element("pandas-dev-console").element.style.display = "block"
|
119 |
+
|
120 |
+
display (df, target="pandas-output-inner", append="False")
|
121 |
+
|
122 |
+
def log(message):
|
123 |
+
# log to pyscript dev console
|
124 |
+
print (message)
|
125 |
+
|
126 |
+
# log to JS console
|
127 |
+
js.console.log (message)
|
128 |
+
</py-script>
|
129 |
+
</section>
|
130 |
+
</py-tutor>
|
131 |
+
</body>
|
132 |
+
</html>
|
style.css
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
padding: 2rem;
|
3 |
+
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
4 |
+
}
|
5 |
+
|
6 |
+
h1 {
|
7 |
+
font-size: 16px;
|
8 |
+
margin-top: 0;
|
9 |
+
}
|
10 |
+
|
11 |
+
p {
|
12 |
+
color: rgb(107, 114, 128);
|
13 |
+
font-size: 15px;
|
14 |
+
margin-bottom: 10px;
|
15 |
+
margin-top: 5px;
|
16 |
+
}
|
17 |
+
|
18 |
+
.card {
|
19 |
+
max-width: 620px;
|
20 |
+
margin: 0 auto;
|
21 |
+
padding: 16px;
|
22 |
+
border: 1px solid lightgray;
|
23 |
+
border-radius: 16px;
|
24 |
+
}
|
25 |
+
|
26 |
+
.card p:last-child {
|
27 |
+
margin-bottom: 0;
|
28 |
+
}
|