-
Notifications
You must be signed in to change notification settings - Fork 66
/
demo.py
executable file
·49 lines (38 loc) · 1.42 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
48
49
#!/usr/bin/env python
# -*- encoding: utf-8
from __future__ import absolute_import, division, print_function
"""
If you are getting wx related import errors when running in a virtualenv:
Either make sure that the virtualenv has been created using
`virtualenv --system-site-packages venv` or manually add the wx library
path (e.g. /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode) to the
python path.
"""
import datetime
import pandas as pd
import numpy as np
import dfgui
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)),
])
df = create_dummy_data(1000)
dfgui.show(df)