-
Notifications
You must be signed in to change notification settings - Fork 10
/
demo.py
executable file
·47 lines (36 loc) · 1.3 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- encoding: utf-8
from __future__ import absolute_import, division, print_function
from kivy.app import App
import datetime
import numpy as np
import pandas as pd
from dfguik import DfguiWidget
def create_dummy_data(size):
user_ids = np.random.randint(1, 1000000, 10)
product_ids = np.random.randint(1, 1000000, 100)
def choice(*values):
return np.random.choice(values, size)
random_dates = [
datetime.date(2016, 1, 1) + datetime.timedelta(days=int(delta))
for delta in np.random.randint(1, 50, size)
]
return pd.DataFrame.from_items([
("Date", random_dates),
("UserID", choice(*user_ids)),
("ProductID", choice(*product_ids)),
("IntColumn", choice(1, 2, 3)),
("FloatColumn", choice(np.nan, 1.0, 2.0, 3.0)),
("StringColumn", choice("A", "B", "C")),
("Gaussian 1", np.random.normal(0, 1, size)),
("Gaussian 2", np.random.normal(0, 1, size)),
("Uniform", np.random.uniform(0, 1, size)),
("Binomial", np.random.binomial(20, 0.1, size)),
("Poisson", np.random.poisson(1.0, size)),
])
class DataFrameApp(App):
def build(self):
df = create_dummy_data(1000)
return DfguiWidget(df)
if __name__ == '__main__':
DataFrameApp().run()