├── .gitignore
├── LICENSE.md
├── MANIFEST.in
├── README.rst
├── example
├── jupyter_pivottablejs_example.ipynb
└── mps.csv
├── pivottablejs
└── __init__.py
├── requirements.txt
├── setup.cfg
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Backup files
2 | *.~
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | bin/
13 | build/
14 | develop-eggs/
15 | dist/
16 | eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | *.egg-info/
23 | .installed.cfg
24 | *.egg
25 | MANIFEST
26 |
27 | # Installer logs
28 | pip-log.txt
29 | pip-delete-this-directory.txt
30 |
31 | # Unit test / coverage reports
32 | .tox/
33 | .coverage
34 | .cache
35 | nosetests.xml
36 | coverage.xml
37 |
38 | # Translations
39 | *.mo
40 |
41 | # Sphinx documentation
42 | docs/_build/example/pivottablejs.html
43 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | (MIT License)
2 |
3 | PivotTable.js is © 2012-2013 Nicolas Kruchten, Datacratic, other contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include LICENSE
2 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | ``pivottablejs``: the Python module
2 | ===================================
3 |
4 | Drag’n’drop Pivot Tables and Charts for `Jupyter/IPython Notebook`_,
5 | care of `PivotTable.js`_
6 |
7 | .. image:: https://mybinder.org/badge_logo.svg
8 | :target: https://mybinder.org/v2/gh/nicolaskruchten/jupyter_pivottablejs/master?filepath=example%2Fjupyter_pivottablejs_example.ipynb
9 |
10 |
11 | Installation
12 | ------------
13 |
14 | ``pip install pivottablejs`` or ``conda install pivottablejs``
15 |
16 | **Note** in the past, the ``conda`` command above installed `pivottablejs-airgap`_ instead of this library; apologies for any confusion this change may cause.
17 |
18 | Usage
19 | -----
20 |
21 | .. code:: python
22 |
23 | import pandas as pd
24 | df = pd.read_csv("some_input.csv")
25 |
26 | from pivottablejs import pivot_ui
27 |
28 | pivot_ui(df)
29 |
30 | Advanced Usage
31 | --------------
32 |
33 | Include any `JSON-serializable option to PivotTable.js's pivotUI() function`_ as a keyword argument.
34 |
35 | .. code:: python
36 |
37 | pivot_ui(df, rows=['row_name'], cols=['col_name'])
38 |
39 | Independently control the output file path and the URL used to access it from Jupyter, in case the default relative-URL behaviour is incompatible with Jupyter's settings.
40 |
41 | .. code:: python
42 |
43 | pivot_ui(df, outfile_path="/x/y.html", url="http://localhost/a/b/x.html")
44 |
45 | .. _Jupyter/IPython Notebook: http://jupyter.org/
46 | .. _PivotTable.js: https://github.com/nicolaskruchten/pivottable
47 | .. _pivottablejs-airgap: https://github.com/ContinuumIO/pivottablejs-airgap
48 | .. _JSON-serializable option to PivotTable.js's pivotUI() function: https://github.com/nicolaskruchten/pivottable/wiki/Parameters#options-object-for-pivotui
49 |
--------------------------------------------------------------------------------
/example/jupyter_pivottablejs_example.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [
8 | {
9 | "data": {
10 | "text/html": [
11 | "
\n",
12 | "\n",
25 | "
\n",
26 | " \n",
27 | " \n",
28 | " \n",
29 | " Name \n",
30 | " Party \n",
31 | " Province \n",
32 | " Age \n",
33 | " Gender \n",
34 | " \n",
35 | " \n",
36 | " \n",
37 | " \n",
38 | " 0 \n",
39 | " Liu, Laurin \n",
40 | " NDP \n",
41 | " Quebec \n",
42 | " 22.0 \n",
43 | " Female \n",
44 | " \n",
45 | " \n",
46 | " 1 \n",
47 | " Mourani, Maria \n",
48 | " Bloc Quebecois \n",
49 | " Quebec \n",
50 | " 43.0 \n",
51 | " Female \n",
52 | " \n",
53 | " \n",
54 | " 2 \n",
55 | " Sellah, Djaouida \n",
56 | " NDP \n",
57 | " Quebec \n",
58 | " NaN \n",
59 | " Female \n",
60 | " \n",
61 | " \n",
62 | " 3 \n",
63 | " St-Denis, Lise \n",
64 | " NDP \n",
65 | " Quebec \n",
66 | " 72.0 \n",
67 | " Female \n",
68 | " \n",
69 | " \n",
70 | " 4 \n",
71 | " Fry, Hedy \n",
72 | " Liberal \n",
73 | " British Columbia \n",
74 | " 71.0 \n",
75 | " Female \n",
76 | " \n",
77 | " \n",
78 | "
\n",
79 | "
"
80 | ],
81 | "text/plain": [
82 | " Name Party Province Age Gender\n",
83 | "0 Liu, Laurin NDP Quebec 22.0 Female\n",
84 | "1 Mourani, Maria Bloc Quebecois Quebec 43.0 Female\n",
85 | "2 Sellah, Djaouida NDP Quebec NaN Female\n",
86 | "3 St-Denis, Lise NDP Quebec 72.0 Female\n",
87 | "4 Fry, Hedy Liberal British Columbia 71.0 Female"
88 | ]
89 | },
90 | "execution_count": 1,
91 | "metadata": {},
92 | "output_type": "execute_result"
93 | }
94 | ],
95 | "source": [
96 | "import pandas as pd\n",
97 | "df = pd.read_csv(\"mps.csv\")\n",
98 | "df.head()"
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": 2,
104 | "metadata": {},
105 | "outputs": [
106 | {
107 | "data": {
108 | "text/html": [
109 | "\n",
110 | " \n",
117 | " "
118 | ],
119 | "text/plain": [
120 | ""
121 | ]
122 | },
123 | "execution_count": 2,
124 | "metadata": {},
125 | "output_type": "execute_result"
126 | }
127 | ],
128 | "source": [
129 | "# note: this will not render on Github, you'll need to run it locally!\n",
130 | "\n",
131 | "from pivottablejs import pivot_ui\n",
132 | "\n",
133 | "pivot_ui(df, \n",
134 | " cols= [\"Party\"],\n",
135 | " rows= [\"Province\"],\n",
136 | " rendererName= \"Horizontal Stacked Bar Chart\",\n",
137 | " rowOrder= \"value_z_to_a\", \n",
138 | " colOrder= \"value_z_to_a\",\n",
139 | " rendererOptions= {\n",
140 | " \"c3\": { \"data\": {\"colors\": {\n",
141 | " \"Liberal\": '#dc3912', \"Conservative\": '#3366cc', \"NDP\": '#ff9900',\n",
142 | " \"Green\":'#109618', 'Bloc Quebecois': '#990099'\n",
143 | " }}}\n",
144 | " }\n",
145 | ")"
146 | ]
147 | },
148 | {
149 | "cell_type": "code",
150 | "execution_count": null,
151 | "metadata": {
152 | "collapsed": true
153 | },
154 | "outputs": [],
155 | "source": []
156 | }
157 | ],
158 | "metadata": {
159 | "anaconda-cloud": {},
160 | "kernelspec": {
161 | "display_name": "Python 3",
162 | "language": "python",
163 | "name": "python3"
164 | },
165 | "language_info": {
166 | "codemirror_mode": {
167 | "name": "ipython",
168 | "version": 3
169 | },
170 | "file_extension": ".py",
171 | "mimetype": "text/x-python",
172 | "name": "python",
173 | "nbconvert_exporter": "python",
174 | "pygments_lexer": "ipython3",
175 | "version": "3.5.3"
176 | }
177 | },
178 | "nbformat": 4,
179 | "nbformat_minor": 1
180 | }
181 |
--------------------------------------------------------------------------------
/example/mps.csv:
--------------------------------------------------------------------------------
1 | Name,Party,Province,Age,Gender
2 | "Liu, Laurin",NDP,Quebec,22,Female
3 | "Mourani, Maria",Bloc Quebecois,Quebec,43,Female
4 | "Sellah, Djaouida",NDP,Quebec,,Female
5 | "St-Denis, Lise",NDP,Quebec,72,Female
6 | "Fry, Hedy",Liberal,British Columbia,71,Female
7 | "Turmel, Nycole",NDP,Quebec,70,Female
8 | "Sgro, Judy",Liberal,Ontario,68,Female
9 | "Raynault, Francine",NDP,Quebec,67,Female
10 | "Davidson, Patricia",Conservative,Ontario,66,Female
11 | "Smith, Joy",Conservative,Manitoba,65,Female
12 | "Wong, Alice",Conservative,British Columbia,64,Female
13 | "O'Neill Gordon, Tilly",Conservative,New Brunswick,63,Female
14 | "Ablonczy, Diane",Conservative,Alberta,63,Female
15 | "Duncan, Linda Francis",NDP,Alberta,63,Female
16 | "Bennett, Carolyn",Liberal,Ontario,62,Female
17 | "Nash, Peggy",NDP,Ontario,61,Female
18 | "Mathyssen, Irene",NDP,Ontario,61,Female
19 | "Sims, Jinny Jogindera",NDP,British Columbia,60,Female
20 | "Foote, Judy",Liberal,Newfoundland and Labrador,60,Female
21 | "Crowder, Jean",NDP,British Columbia,60,Female
22 | "Davies, Libby",NDP,British Columbia,59,Female
23 | "Yelich, Lynne",Conservative,Saskatchewan,59,Female
24 | "Day, Anne-Marie",NDP,Quebec,58,Female
25 | "May, Elizabeth",Green,British Columbia,58,Female
26 | "Murray, Joyce",Liberal,British Columbia,58,Female
27 | "Findlay, Kerry-Lynne D.",Conservative,British Columbia,57,Female
28 | "Brown, Lois",Conservative,Ontario,57,Female
29 | "Laverdière, Hélène",NDP,Quebec,57,Female
30 | "Boutin-Sweet, Marjolaine",NDP,Quebec,57,Female
31 | "Crockatt, Joan",Conservative,Alberta,56,Female
32 | "Chow, Olivia",NDP,Ontario,55,Female
33 | "McLeod, Cathy",Conservative,British Columbia,55,Female
34 | "Finley, Diane",Conservative,Ontario,55,Female
35 | "LeBlanc, Hélène",NDP,Quebec,54,Female
36 | "Grewal, Nina",Conservative,British Columbia,54,Female
37 | "Hughes, Carol",NDP,Ontario,54,Female
38 | "Shea, Gail",Conservative,Prince Edward Island,53,Female
39 | "Truppe, Susan",Conservative,Ontario,53,Female
40 | "Young, Wai",Conservative,British Columbia,52,Female
41 | "Gallant, Cheryl",Conservative,Ontario,52,Female
42 | "Boivin, Françoise",NDP,Quebec,52,Female
43 | "Block, Kelly",Conservative,Saskatchewan,51,Female
44 | "Ayala, Paulina",NDP,Quebec,50,Female
45 | "Groguhé, Sadia",NDP,Quebec,50,Female
46 | "Charlton, Chris",NDP,Ontario,49,Female
47 | "Bergen, Candice",Conservative,Manitoba,48,Female
48 | "Perreault, Manon",NDP,Quebec,46,Female
49 | "James, Roxanne",Conservative,Ontario,46,Female
50 | "Ambler, Stella",Conservative,Ontario,46,Female
51 | "Duncan, Kirsty",Liberal,Ontario,46,Female
52 | "Glover, Shelly",Conservative,Manitoba,45,Female
53 | "Aglukkaq, Leona",Conservative,Territories,45,Female
54 | "Raitt, Lisa",Conservative,Ontario,44,Female
55 | "Ambrose, Rona",Conservative,Alberta,43,Female
56 | "Leitch, Kellie",Conservative,Ontario,42,Female
57 | "Leslie, Megan",NDP,Nova Scotia,39,Female
58 | "Hassainia, Sana",NDP,Quebec,38,Female
59 | "Adams, Eve",Conservative,Ontario,38,Female
60 | "Rempel, Michelle",Conservative,Alberta,32,Female
61 | "Papillon, Annick",NDP,Quebec,32,Female
62 | "Sitsabaiesan, Rathika",NDP,Ontario,31,Female
63 | "Quach, Anne Minh-Thu",NDP,Quebec,30,Female
64 | "Ashton, Niki",NDP,Manitoba,30,Female
65 | "Moore, Christine",NDP,Quebec,29,Female
66 | "Morin, Isabelle",NDP,Quebec,28,Female
67 | "Blanchette-Lamothe, Lysane",NDP,Quebec,28,Female
68 | "Brosseau, Ruth Ellen",NDP,Quebec,28,Female
69 | "Latendresse, Alexandrine",NDP,Quebec,28,Female
70 | "Doré Lefebvre, Rosane",NDP,Quebec,28,Female
71 | "Morin, Marie-Claude",NDP,Quebec,27,Female
72 | "Michaud, Élaine",NDP,Quebec,27,Female
73 | "Péclet, Ève",NDP,Quebec,24,Female
74 | "Freeman, Mylène",NDP,Quebec,23,Female
75 | "Borg, Charmaine",NDP,Quebec,22,Female
76 | "Bateman, Joyce",Conservative,Manitoba,,Female
77 | "Hiebert, Russ",Conservative,British Columbia,43,Male
78 | "Jacob, Pierre",NDP,Quebec,59,Male
79 | "Vellacott, Maurice",Conservative,Saskatchewan,57,Male
80 | "Boughen, Ray",Conservative,Saskatchewan,75,Male
81 | "O'Connor, Gordon",Conservative,Ontario,73,Male
82 | "Cotler, Irwin",Liberal,Quebec,72,Male
83 | "Oliver, Joe",Conservative,Ontario,72,Male
84 | "Tilson, David Allan",Conservative,Ontario,71,Male
85 | "Fantino, Julian",Conservative,Ontario,70,Male
86 | "Kent, Peter",Conservative,Ontario,69,Male
87 | "Plamondon, Louis",Bloc Quebecois,Quebec,69,Male
88 | "Schellenberger, Gary",Conservative,Ontario,69,Male
89 | "Lauzon, Guy",Conservative,Ontario,68,Male
90 | "Harris, Richard M.",Conservative,British Columbia,68,Male
91 | "Goldring, Peter",Conservative,Alberta,68,Male
92 | "Atamanenko, Alex",NDP,British Columbia,67,Male
93 | "Payne, LaVar",Conservative,Alberta,67,Male
94 | "Breitkreuz, Garry W.",Conservative,Saskatchewan,67,Male
95 | "Genest, Réjean",NDP,Quebec,66,Male
96 | "MacKenzie, Dave",Conservative,Ontario,66,Male
97 | "Hyer, Bruce",NDP,Ontario,66,Male
98 | "MacAulay, Lawrence",Liberal,Prince Edward Island,66,Male
99 | "Galipeau, Royal",Conservative,Ontario,65,Male
100 | "Marston, Wayne",NDP,Ontario,65,Male
101 | "Hawn, Laurie",Conservative,Alberta,65,Male
102 | "Kramp, Daryl",Conservative,Ontario,65,Male
103 | "Shipley, Bev",Conservative,Ontario,65,Male
104 | "Kerr, Greg",Conservative,Nova Scotia,65,Male
105 | "Comartin, Joe",NDP,Ontario,65,Male
106 | "Norlock, Rick",Conservative,Ontario,64,Male
107 | "McKay, John",Liberal,Ontario,64,Male
108 | "Mayes, Colin",Conservative,British Columbia,64,Male
109 | "Rae, Bob",Liberal,Ontario,64,Male
110 | "Harris, Jack",NDP,Newfoundland and Labrador,64,Male
111 | "Duncan, John",Conservative,British Columbia,64,Male
112 | "Chisu, Corneliu",Conservative,Ontario,63,Male
113 | "Garneau, Marc",Liberal,Quebec,63,Male
114 | "Easter, Arnold Wayne",Liberal,Prince Edward Island,63,Male
115 | "Aspin, Jay",Conservative,Ontario,63,Male
116 | "Goodale, Ralph",Liberal,Saskatchewan,63,Male
117 | "Albrecht, Harold",Conservative,Ontario,63,Male
118 | "Gravelle, Claude",NDP,Ontario,63,Male
119 | "Komarnicki, Ed",Conservative,Saskatchewan,63,Male
120 | "Flaherty, James Michael (Jim)",Conservative,Ontario,62,Male
121 | "Rankin, Murray",NDP,British Columbia,62,Male
122 | "McCallum, John",Liberal,Ontario,62,Male
123 | "Warawa, Mark",Conservative,British Columbia,62,Male
124 | "Obhrai, Deepak",Conservative,Alberta,62,Male
125 | "Benoit, Leon Earl",Conservative,Alberta,62,Male
126 | "Leung, Chungsen",Conservative,Ontario,62,Male
127 | "Morin, Marc-André",NDP,Quebec,61,Male
128 | "Sopuck, Robert",Conservative,Manitoba,61,Male
129 | "Ritz, Gerry",Conservative,Saskatchewan,61,Male
130 | "Garrison, Randall",NDP,British Columbia,61,Male
131 | "Lunney, James",Conservative,British Columbia,61,Male
132 | "Lukiwski, Tom",Conservative,Saskatchewan,61,Male
133 | "Carmichael, John",Conservative,Ontario,60,Male
134 | "Menzies, Ted",Conservative,Alberta,60,Male
135 | "Valcourt, Bernard",Conservative,New Brunswick,60,Male
136 | "Ashfield, Keith",Conservative,New Brunswick,60,Male
137 | "Nicholson, Rob",Conservative,Ontario,60,Male
138 | "Young, Terence H.",Conservative,Ontario,60,Male
139 | "Toews, Vic",Conservative,Manitoba,60,Male
140 | "Sullivan, Mike",NDP,Ontario,60,Male
141 | "Patry, Claude",NDP,Quebec,59,Male
142 | "Keddy, Gerald",Conservative,Nova Scotia,59,Male
143 | "Bevington, Dennis Fraser",NDP,Territories,59,Male
144 | "Allen, Malcolm",NDP,Ontario,59,Male
145 | "Rafferty, John",NDP,Ontario,59,Male
146 | "Dreeshen, Earl",Conservative,Alberta,59,Male
147 | "Kamp, Randy",Conservative,British Columbia,59,Male
148 | "Merrifield, Rob",Conservative,Alberta,59,Male
149 | "Woodworth, Stephen",Conservative,Ontario,58,Male
150 | "McColeman, Phil",Conservative,Ontario,58,Male
151 | "Lebel, Denis",Conservative,Quebec,58,Male
152 | "Lizon, Wladyslaw",Conservative,Ontario,58,Male
153 | "Holder, Ed",Conservative,Ontario,58,Male
154 | "Valeriote, Frank",Liberal,Ontario,58,Male
155 | "Christopherson, David",NDP,Ontario,58,Male
156 | "Mulcair, Thomas J.",NDP,Quebec,58,Male
157 | "Daniel, Joe",Conservative,Ontario,58,Male
158 | "Karygiannis, Jim",Liberal,Ontario,57,Male
159 | "Godin, Yvon",NDP,New Brunswick,57,Male
160 | "Dionne Labelle, Pierre",NDP,Quebec,57,Male
161 | "Preston, Joe",Conservative,Ontario,57,Male
162 | "Bélanger, Mauril",Liberal,Ontario,57,Male
163 | "Fast, Edward",Conservative,British Columbia,57,Male
164 | "Tweed, Mervin C.",Conservative,Manitoba,57,Male
165 | "Dion, Stéphane",Liberal,Quebec,57,Male
166 | "Van Kesteren, Dave",Conservative,Ontario,57,Male
167 | "Cuzner, Rodger",Liberal,Nova Scotia,57,Male
168 | "Martin, Pat",NDP,Manitoba,57,Male
169 | "Stoffer, Peter",NDP,Nova Scotia,56,Male
170 | "Miller, Larry",Conservative,Ontario,56,Male
171 | "Blanchette, Denis",NDP,Quebec,56,Male
172 | "Nunez-Melo, José",NDP,Quebec,56,Male
173 | "Goguen, Robert",Conservative,New Brunswick,55,Male
174 | "Scarpaleggia, Francis",Liberal,Quebec,55,Male
175 | "Sweet, David",Conservative,Ontario,55,Male
176 | "Anderson, David",Conservative,Saskatchewan,55,Male
177 | "Chisholm, Robert",NDP,Nova Scotia,55,Male
178 | "Stanton, Bruce",Conservative,Ontario,55,Male
179 | "Goodyear, Gary",Conservative,Ontario,54,Male
180 | "Weston, John",Conservative,British Columbia,54,Male
181 | "Dechert, Bob",Conservative,Ontario,54,Male
182 | "Shory, Devinder",Conservative,Alberta,54,Male
183 | "Pilon, François",NDP,Quebec,54,Male
184 | "Hayes, Bryan",Conservative,Ontario,54,Male
185 | "Giguère, Alain",NDP,Quebec,54,Male
186 | "Sorenson, Kevin",Conservative,Alberta,54,Male
187 | "Benskin, Tyrone",NDP,Quebec,53,Male
188 | "Menegakis, Costas",Conservative,Ontario,53,Male
189 | "Harper, Stephen",Conservative,Alberta,53,Male
190 | "Wilks, David",Conservative,British Columbia,53,Male
191 | "Regan, Geoff",Liberal,Nova Scotia,53,Male
192 | "McGuinty, David",Liberal,Ontario,52,Male
193 | "Gosal, Bal",Conservative,Ontario,52,Male
194 | "Aubin, Robert",NDP,Quebec,52,Male
195 | "Eyking, Mark",Liberal,Nova Scotia,52,Male
196 | "Brown, Gordon",Conservative,Ontario,52,Male
197 | "Allen, Mike",Conservative,New Brunswick,52,Male
198 | "Clement, Tony",Conservative,Ontario,51,Male
199 | "Cannan, Ronald",Conservative,British Columbia,51,Male
200 | "Rousseau, Jean",NDP,Quebec,51,Male
201 | "Opitz, Ted",Conservative,Ontario,51,Male
202 | "Toet, Lawrence",Conservative,Manitoba,50,Male
203 | "Cash, Andrew",NDP,Ontario,50,Male
204 | "Lamoureux, Kevin",Liberal,Manitoba,50,Male
205 | "Scott, Craig",NDP,Ontario,50,Male
206 | "Adler, Mark",Conservative,Ontario,50,Male
207 | "Carrie, Colin",Conservative,Ontario,50,Male
208 | "Julian, Peter",NDP,British Columbia,50,Male
209 | "Pacetti, Massimo",Liberal,Quebec,50,Male
210 | "Saganash, Romeo",NDP,Quebec,50,Male
211 | "Angus, Charlie",NDP,Ontario,50,Male
212 | "Davies, Don",NDP,British Columbia,49,Male
213 | "Bernier, Maxime",Conservative,Quebec,49,Male
214 | "Dewar, Paul",NDP,Ontario,49,Male
215 | "Jean, Brian",Conservative,Alberta,49,Male
216 | "Devolin, Barry",Conservative,Ontario,49,Male
217 | "Lemieux, Pierre",Conservative,Ontario,49,Male
218 | "Van Loan, Peter",Conservative,Ontario,49,Male
219 | "Casey, Sean",Liberal,Prince Edward Island,49,Male
220 | "Nantel, Pierre",NDP,Quebec,49,Male
221 | "Coderre, Denis",Liberal,Quebec,49,Male
222 | "Wallace, Mike",Conservative,Ontario,49,Male
223 | "Braid, Peter",Conservative,Ontario,48,Male
224 | "Gourde, Jacques",Conservative,Quebec,48,Male
225 | "Reid, Scott",Conservative,Ontario,48,Male
226 | "Hsu, Ted",Liberal,Ontario,48,Male
227 | "Saxton, Andrew",Conservative,British Columbia,48,Male
228 | "Weston, Rodney",Conservative,New Brunswick,48,Male
229 | "Penashue, Peter",Conservative,Newfoundland and Labrador,48,Male
230 | "Bellavance, André",Bloc Quebecois,Quebec,48,Male
231 | "Rathgeber, Brent",Conservative,Alberta,48,Male
232 | "Kellway, Matthew",NDP,Ontario,48,Male
233 | "Toone, Philip",NDP,Quebec,47,Male
234 | "Allison, Dean",Conservative,Ontario,47,Male
235 | "Trottier, Bernard",Conservative,Ontario,47,Male
236 | "Blaney, Steven",Conservative,Quebec,47,Male
237 | "Bezan, James",Conservative,Manitoba,47,Male
238 | "MacKay, Peter Gordon",Conservative,Nova Scotia,47,Male
239 | "Dykstra, Richard",Conservative,Ontario,46,Male
240 | "Sandhu, Jasbir",NDP,British Columbia,46,Male
241 | "Donnelly, Fin",NDP,British Columbia,46,Male
242 | "Armstrong, Scott",Conservative,Nova Scotia,46,Male
243 | "Byrne, Gerry",Liberal,Newfoundland and Labrador,46,Male
244 | "Stewart, Kennedy",NDP,British Columbia,46,Male
245 | "Cleary, Ryan",NDP,Newfoundland and Labrador,46,Male
246 | "Côté, Raymond",NDP,Quebec,45,Male
247 | "Clarke, Rob",Conservative,Saskatchewan,45,Male
248 | "Brison, Scott",Liberal,Nova Scotia,45,Male
249 | "Butt, Brad",Conservative,Ontario,45,Male
250 | "Rickford, Greg",Conservative,Ontario,45,Male
251 | "LeBlanc, Dominic",Liberal,New Brunswick,45,Male
252 | "Hoback, Randy",Conservative,Saskatchewan,45,Male
253 | "Caron, Guy",NDP,Quebec,44,Male
254 | "Brahmi, Tarik",NDP,Quebec,44,Male
255 | "Kenney, Jason",Conservative,Alberta,44,Male
256 | "Masse, Brian",NDP,Ontario,44,Male
257 | "Alexander, Chris",Conservative,Ontario,44,Male
258 | "Zimmer, Bob",Conservative,British Columbia,44,Male
259 | "Calkins, Blaine",Conservative,Alberta,44,Male
260 | "Baird, John",Conservative,Ontario,43,Male
261 | "Lake, Mike",Conservative,Alberta,43,Male
262 | "Simms, Scott",Liberal,Newfoundland and Labrador,43,Male
263 | "Thibeault, Glenn",NDP,Ontario,43,Male
264 | "Williamson, John",Conservative,New Brunswick,42,Male
265 | "Calandra, Paul",Conservative,Ontario,42,Male
266 | "Chicoine, Sylvain",NDP,Quebec,42,Male
267 | "Del Mastro, Dean",Conservative,Ontario,42,Male
268 | "Rajotte, James",Conservative,Alberta,42,Male
269 | "Seeback, Kyle",Conservative,Ontario,42,Male
270 | "Watson, Jeff",Conservative,Ontario,41,Male
271 | "Lapointe, François",NDP,Quebec,41,Male
272 | "Nicholls, Jamie",NDP,Quebec,41,Male
273 | "Chong, Michael D.",Conservative,Ontario,41,Male
274 | "Trudeau, Justin",Liberal,Quebec,41,Male
275 | "Larose, Jean-François",NDP,Quebec,40,Male
276 | "Anders, Rob",Conservative,Alberta,40,Male
277 | "Fletcher, Steven John",Conservative,Manitoba,40,Male
278 | "Cullen, Nathan",NDP,British Columbia,40,Male
279 | "Ravignat, Mathieu",NDP,Quebec,39,Male
280 | "Bruinooge, Rod",Conservative,Manitoba,39,Male
281 | "Mai, Hoang",NDP,Quebec,39,Male
282 | "Boulerice, Alexandre",NDP,Quebec,39,Male
283 | "Fortin, Jean-François",Bloc Quebecois,Quebec,39,Male
284 | "Leef, Ryan",Conservative,Territories,38,Male
285 | "Paradis, Christian",Conservative,Quebec,38,Male
286 | "Choquette, François",NDP,Quebec,38,Male
287 | "Moore, Rob",Conservative,New Brunswick,38,Male
288 | "Trost, Brad",Conservative,Saskatchewan,38,Male
289 | "Gill, Parm",Conservative,Ontario,38,Male
290 | "Hillyer, Jim",Conservative,Alberta,38,Male
291 | "Richards, Blake",Conservative,Alberta,38,Male
292 | "Uppal, Tim",Conservative,Alberta,38,Male
293 | "Andrews, Scott",Liberal,Newfoundland and Labrador,37,Male
294 | "Moore, James",Conservative,British Columbia,36,Male
295 | "Lobb, Ben",Conservative,Ontario,36,Male
296 | "Albas, Dan",Conservative,British Columbia,36,Male
297 | "Storseth, Brian",Conservative,Alberta,34,Male
298 | "Strahl, Mark",Conservative,British Columbia,34,Male
299 | "Brown, Patrick W.",Conservative,Ontario,34,Male
300 | "Warkentin, Chris",Conservative,Alberta,34,Male
301 | "Scheer, Andrew",Conservative,Saskatchewan,33,Male
302 | "Poilievre, Pierre",Conservative,Ontario,33,Male
303 | "Genest-Jourdain, Jonathan",NDP,Quebec,33,Male
304 | "Harris, Dan",NDP,Ontario,33,Male
305 | "Tremblay, Jonathan",NDP,Quebec,28,Male
306 | "Morin, Dany",NDP,Quebec,27,Male
307 | "Dubé, Matthew",NDP,Quebec,24,Male
308 | "Dusseault, Pierre-Luc",NDP,Quebec,21,Male
309 | "O'Toole, Erin",Conservative,Ontario,,Male
310 |
--------------------------------------------------------------------------------
/pivottablejs/__init__.py:
--------------------------------------------------------------------------------
1 | TEMPLATE = u"""
2 |
3 |
4 |
5 |
6 | PivotTable.js
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
41 |
42 |
43 |
63 | %(csv)s
64 |
65 |
66 | """
67 |
68 | from IPython.display import IFrame
69 | import json, io
70 |
71 | def pivot_ui(df, outfile_path = "pivottablejs.html", url="",
72 | width="100%", height="500", **kwargs):
73 | with io.open(outfile_path, 'wt', encoding='utf8') as outfile:
74 | csv = df.to_csv(encoding='utf8')
75 | if hasattr(csv, 'decode'):
76 | csv = csv.decode('utf8')
77 | outfile.write(TEMPLATE %
78 | dict(csv=csv, kwargs=json.dumps(kwargs)))
79 | return IFrame(src=url or outfile_path, width=width, height=height)
80 |
81 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pandas
2 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [bdist_wheel]
2 | # This flag says that the code is written to work on both Python 2 and Python
3 | # 3. If at all possible, it is good practice to do this. If you cannot, you
4 | # will need to generate wheels for each Python version that you support.
5 | universal=1
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | """A setuptools based setup module.
2 | See:
3 | https://packaging.python.org/en/latest/distributing.html
4 | https://github.com/pypa/sampleproject
5 | """
6 |
7 | # Always prefer setuptools over distutils
8 | from setuptools import setup, find_packages
9 | # To use a consistent encoding
10 | from codecs import open
11 | from os import path
12 |
13 | here = path.abspath(path.dirname(__file__))
14 |
15 | # Get the long description from the relevant file
16 | with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
17 | long_description = f.read()
18 |
19 | setup(
20 | name='pivottablejs',
21 |
22 | # Versions should comply with PEP440. For a discussion on single-sourcing
23 | # the version across setup.py and the project code, see
24 | # https://packaging.python.org/en/latest/single_source_version.html
25 | version='0.9.0',
26 |
27 | description='PivotTable.js integration for Jupyter/IPython Notebook',
28 | long_description=long_description,
29 |
30 | # The project's main homepage.
31 | url='https://github.com/nicolaskruchten/jupyter_pivottablejs',
32 |
33 | # Author details
34 | author='Nicolas Kruchten',
35 | author_email='nicolas@kruchten.com',
36 |
37 | # Choose your license
38 | license='MIT',
39 |
40 | # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
41 | classifiers=[
42 | # How mature is this project? Common values are
43 | # 3 - Alpha
44 | # 4 - Beta
45 | # 5 - Production/Stable
46 | 'Development Status :: 4 - Beta',
47 |
48 | # Indicate who your project is intended for
49 | 'Intended Audience :: Developers',
50 | 'Intended Audience :: Science/Research',
51 | 'Intended Audience :: End Users/Desktop',
52 | 'Topic :: Scientific/Engineering :: Information Analysis',
53 | 'Topic :: Scientific/Engineering :: Visualization',
54 | 'Topic :: Utilities',
55 | 'Environment :: Web Environment',
56 | 'Framework :: IPython',
57 |
58 | # Pick your license as you wish (should match "license" above)
59 | 'License :: OSI Approved :: MIT License',
60 |
61 | # Specify the Python versions you support here. In particular, ensure
62 | # that you indicate whether you support Python 2, Python 3 or both.
63 | 'Programming Language :: Python :: 2',
64 | 'Programming Language :: Python :: 3',
65 | 'Programming Language :: JavaScript'
66 | ],
67 |
68 | # What does your project relate to?
69 | keywords='pivot table grid pivottable pivotgrid pivotchart crosstab',
70 |
71 | # You can just specify the packages manually here if your project is
72 | # simple. Or you can use find_packages().
73 | packages=["pivottablejs"]
74 |
75 | )
76 |
--------------------------------------------------------------------------------