pyjstat-smooth 2.5.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.
- pyjstat_smooth-2.5.0/.coveragerc +2 -0
- pyjstat_smooth-2.5.0/.travis.yml +5 -0
- pyjstat_smooth-2.5.0/CHANGES.txt +22 -0
- pyjstat_smooth-2.5.0/LICENSE.txt +201 -0
- pyjstat_smooth-2.5.0/MANIFEST.in +20 -0
- pyjstat_smooth-2.5.0/PKG-INFO +210 -0
- pyjstat_smooth-2.5.0/README.rst +172 -0
- pyjstat_smooth-2.5.0/docs/Makefile +153 -0
- pyjstat_smooth-2.5.0/docs/build/.buildinfo +4 -0
- pyjstat_smooth-2.5.0/docs/build/doctrees/environment.pickle +0 -0
- pyjstat_smooth-2.5.0/docs/build/doctrees/index.doctree +0 -0
- pyjstat_smooth-2.5.0/docs/build/doctrees/modules.doctree +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/.buildinfo +4 -0
- pyjstat_smooth-2.5.0/docs/build/html/_sources/index.txt +28 -0
- pyjstat_smooth-2.5.0/docs/build/html/_sources/modules.txt +7 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/ajax-loader.gif +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/basic.css +768 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/comment-bright.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/comment-close.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/comment.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/default.css +1 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/doctools.js +315 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/down-pressed.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/down.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/file.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/jquery.js +2 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/minus.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/plus.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/pygments.css +69 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/searchtools.js +512 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/sidebar.js +159 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/underscore.js +31 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/up-pressed.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/up.png +0 -0
- pyjstat_smooth-2.5.0/docs/build/html/_static/websupport.js +808 -0
- pyjstat_smooth-2.5.0/docs/build/html/genindex.html +235 -0
- pyjstat_smooth-2.5.0/docs/build/html/index.html +124 -0
- pyjstat_smooth-2.5.0/docs/build/html/modules.html +714 -0
- pyjstat_smooth-2.5.0/docs/build/html/objects.inv +9 -0
- pyjstat_smooth-2.5.0/docs/build/html/py-modindex.html +100 -0
- pyjstat_smooth-2.5.0/docs/build/html/search.html +93 -0
- pyjstat_smooth-2.5.0/docs/build/html/searchindex.js +1 -0
- pyjstat_smooth-2.5.0/docs/class_diagram.puml +39 -0
- pyjstat_smooth-2.5.0/docs/make.bat +190 -0
- pyjstat_smooth-2.5.0/docs/source/conf.py +247 -0
- pyjstat_smooth-2.5.0/docs/source/index.rst +28 -0
- pyjstat_smooth-2.5.0/docs/source/modules.rst +7 -0
- pyjstat_smooth-2.5.0/examples/example-2.0.py +33 -0
- pyjstat_smooth-2.5.0/examples/example.py +14 -0
- pyjstat_smooth-2.5.0/pyjstat/__init__.py +2 -0
- pyjstat_smooth-2.5.0/pyjstat/pyjstat.py +1432 -0
- pyjstat_smooth-2.5.0/pyjstat/test/__init__.py +2 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/A02Level.json +63558 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/CPI15.json +34355 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/QS104EW.json +27 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/cantabria.json +5636 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/collection.json +51 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/dimension.json +13 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/galicia-2.0.json +124 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/galicia-ds.json +115 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/galicia.json +115 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/oecd-canada.json +308 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/ons.json +510 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/sample_data.json +1 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/statswe.json +1 -0
- pyjstat_smooth-2.5.0/pyjstat/test/data/us-labor-ds.json +6519 -0
- pyjstat_smooth-2.5.0/pyjstat/test/test_import.py +35 -0
- pyjstat_smooth-2.5.0/pyjstat/test/test_unit.py +935 -0
- pyjstat_smooth-2.5.0/pyjstat_smooth.egg-info/PKG-INFO +210 -0
- pyjstat_smooth-2.5.0/pyjstat_smooth.egg-info/SOURCES.txt +76 -0
- pyjstat_smooth-2.5.0/pyjstat_smooth.egg-info/dependency_links.txt +1 -0
- pyjstat_smooth-2.5.0/pyjstat_smooth.egg-info/requires.txt +2 -0
- pyjstat_smooth-2.5.0/pyjstat_smooth.egg-info/top_level.txt +1 -0
- pyjstat_smooth-2.5.0/pyproject.toml +3 -0
- pyjstat_smooth-2.5.0/requirements.txt +2 -0
- pyjstat_smooth-2.5.0/setup.cfg +12 -0
- pyjstat_smooth-2.5.0/setup.py +36 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
v2.5.0 09-10-2026 -- First release as pyjstat-smooth (maintained fork). Added compatibility mechanism.
|
|
2
|
+
v2.4.0 07-02-2023 -- Dataset.read() Add parameter 'fill_category' when it uses a DataFrame, which will be checked if its complete and, if is possible, it will fix it to build the output.
|
|
3
|
+
v2.3.0 20-07-2022 -- to_json_stat() accepts note, role and unit.
|
|
4
|
+
v2.2.1 11-08-2021 -- Fixes #30. Solved import behavior.
|
|
5
|
+
v2.2.0 03-22-2020 -- to_json_stat() accepts now source and updated JSON-stat metadata.
|
|
6
|
+
v2.1.0 03-22-2020 -- Dataset.read() accepts now to_json_stat() optional arguments, to pass a different value column name.
|
|
7
|
+
v2.0.0 02-23-2020 -- Use Pandas 1.X, not backwards compatible. Changed to pytest and pipenv. Accepted PR to potentially disable SSL checks when requesting URLs.
|
|
8
|
+
v1.1.0, 03-03-2017 -- Fixes issues #20 and #22.
|
|
9
|
+
v1.0.1, 03-03-2017 -- Trying to fix pypi RST parsing problems.
|
|
10
|
+
v1.0.0, 02-03-2017 -- Major version release with support for JSON-stat 2.0 datasets, collections and dimensions. Performance improvements. Fixed bug with sparse datasets. Simplified API.
|
|
11
|
+
v0.3.5, 10-24-2016 -- Fixed problem with missing values. Refactored code.
|
|
12
|
+
v0.3.4, 10-02-2016 -- Had to use pandas 0.18.1 version. Problems building 0.19.0 in travis ci.
|
|
13
|
+
v0.3.3, 10-02-2016 -- Fixes #12. Added dimension elements sorting by index when reading json-stat.Added new test case.
|
|
14
|
+
v0.3.2, 11-26-2015 -- Fixes #9. Removed useless code about numeric conversion. Fixed bug making zeroes appear as null in to_json_stat(). Added new test cases.
|
|
15
|
+
v0.3.1, 09-04-2015 -- Solved unicode incompatibilities between Python 2 and 3. Removed zero trailing function in dataframe values and changed labels integer values by strings.
|
|
16
|
+
v0.3.0, 08-20-2015 -- Added initial support for JSON-stat 1.03 datasets. Moved sample test data to files. Added more tests with more real datasets, improved examples, made some minor code improvements and fixes (such as to_json dict order, avoid popping the values list in to_dataframe conversion and unicode issues with Python 3).
|
|
17
|
+
v0.2.0, 08-16-2015 -- Changed example to work with requests module instead of urllib2. Also, fixed code and tests to work in Python 3.4 too. Added Travis CI server synced with Github.
|
|
18
|
+
v0.1.9, 08-15-2015 -- Fixed reported minor bugs and pylint issues. Added value column name as optional parameter in json to dataframe methods.
|
|
19
|
+
v0.1.3, 05-22-2014 -- removed bin references from setup.py.
|
|
20
|
+
v0.1.2, 05-22-2014 -- fixed TypeError in to_json_stat().
|
|
21
|
+
v0.1.1, 05-22-2014 -- Moved example.py from bin directory.
|
|
22
|
+
v0.1.0, 05-22-2014 -- Initial release.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
include *.txt
|
|
2
|
+
include .travis.yml
|
|
3
|
+
include .coveragerc
|
|
4
|
+
recursive-include docs *.puml
|
|
5
|
+
recursive-include examples *.py
|
|
6
|
+
recursive-include docs *.bat
|
|
7
|
+
recursive-include docs *.buildinfo
|
|
8
|
+
recursive-include docs *.css
|
|
9
|
+
recursive-include docs *.doctree
|
|
10
|
+
recursive-include docs *.gif
|
|
11
|
+
recursive-include docs *.html
|
|
12
|
+
recursive-include docs *.inv
|
|
13
|
+
recursive-include docs *.js
|
|
14
|
+
recursive-include docs *.pickle
|
|
15
|
+
recursive-include docs *.png
|
|
16
|
+
recursive-include docs *.py
|
|
17
|
+
recursive-include docs *.rst
|
|
18
|
+
recursive-include docs *.txt
|
|
19
|
+
recursive-include docs Makefile
|
|
20
|
+
recursive-include pyjstat *.json
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyjstat-smooth
|
|
3
|
+
Version: 2.5.0
|
|
4
|
+
Summary: Maintained fork of pyjstat: handle JSON-stat data in python using pandas DataFrames.
|
|
5
|
+
Home-page: https://github.com/xor34/pyjstat
|
|
6
|
+
Author: Miguel Expósito Martín
|
|
7
|
+
Author-email: miguel.exposito@gmail.com
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Keywords: json-stat,json,statistics,dataframe,converter
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/x-rst
|
|
23
|
+
License-File: LICENSE.txt
|
|
24
|
+
Requires-Dist: pandas
|
|
25
|
+
Requires-Dist: requests
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: keywords
|
|
33
|
+
Dynamic: license
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: requires-dist
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
**LAST RELEASE 2.0**: update to 2.0 version is highly recommended, since it
|
|
40
|
+
supports JSON-stat 2.0 and brings other improvements. Also, Version 2.X starts
|
|
41
|
+
to **support Pandas 1.X, and won't have backwards compatibility**.
|
|
42
|
+
**WARNING**: support for Python 2.7 has been removed in pyjstat 2.0.
|
|
43
|
+
|
|
44
|
+
=======
|
|
45
|
+
pyjstat
|
|
46
|
+
=======
|
|
47
|
+
|
|
48
|
+
.. image:: https://travis-ci.org/predicador37/pyjstat.svg?branch=master
|
|
49
|
+
:target: https://travis-ci.org/predicador37/pyjstat
|
|
50
|
+
|
|
51
|
+
**pyjstat** is a python library for **JSON-stat** formatted data manipulation
|
|
52
|
+
which allows reading and writing JSON-stat [1]_ format with python,using the
|
|
53
|
+
DataFrame structures provided by the widely accepted pandas library [2]_.
|
|
54
|
+
The JSON-stat format is a simple lightweight JSON format for data
|
|
55
|
+
dissemination, currently in its 2.0 version.
|
|
56
|
+
Pyjstat is inspired in rjstat [3]_, a library to read and write
|
|
57
|
+
JSON-stat with R, by ajschumacher. Note that, like in the rjstat project,
|
|
58
|
+
not all features are supported (i.e. not all metadata are converted).
|
|
59
|
+
**pyjstat** is provided under the Apache License 2.0.
|
|
60
|
+
|
|
61
|
+
.. [1] http://json-stat.org/ for JSON-stat information
|
|
62
|
+
.. [2] http://pandas.pydata.org for Python Data Analysis Library information
|
|
63
|
+
.. [3] https://github.com/ajschumacher/rjstat for rjstat library information
|
|
64
|
+
|
|
65
|
+
This library was first developed to work with Python 2.7. With some fixes
|
|
66
|
+
(thanks to @andrekittredge), now it works with Python 3.4 too.
|
|
67
|
+
|
|
68
|
+
Support for JSON-stat 1.3 and 2.0 is provided. JSON-stat 1.3 methods are
|
|
69
|
+
deprecated now and shouldn't be used in the future, but backwards compatibility
|
|
70
|
+
has been preserved.
|
|
71
|
+
|
|
72
|
+
Pyjstat 1.0 is aimed for simplicity. JSON-stat classes have been replicated
|
|
73
|
+
(Dataset, Collection and Dimension) and provided with simple read() and write()
|
|
74
|
+
methods. Funcionality covers common use cases as having a URL or dataframe
|
|
75
|
+
as data sources.
|
|
76
|
+
|
|
77
|
+
Methods for retrieving the value of a particular cube cell are taken from the
|
|
78
|
+
JSON-stat Javascript sample code. Thanks to @badosa for this.
|
|
79
|
+
|
|
80
|
+
Also, version 1.0 makes use of the requests package internally, which should
|
|
81
|
+
make downloading of datasets easier.
|
|
82
|
+
|
|
83
|
+
Test coverage is 88% and Travis CI is used.
|
|
84
|
+
|
|
85
|
+
Finally, note that the new classes and methods are inspired by JSON-stat 2.0,
|
|
86
|
+
and hence, won't work with previous versions of JSON-stat. However, older
|
|
87
|
+
methods are still available incorporating bug fixes and performance
|
|
88
|
+
improvements.
|
|
89
|
+
|
|
90
|
+
Installation
|
|
91
|
+
============
|
|
92
|
+
|
|
93
|
+
pyjstat requires pandas package. For installation::
|
|
94
|
+
|
|
95
|
+
pip install pyjstat
|
|
96
|
+
|
|
97
|
+
Usage of version 1.0 and newer (with JSON-stat 2.0 support)
|
|
98
|
+
===========================================================
|
|
99
|
+
|
|
100
|
+
Dataset operations: read and write
|
|
101
|
+
----------------------------------
|
|
102
|
+
|
|
103
|
+
Typical usage often looks like this::
|
|
104
|
+
|
|
105
|
+
from pyjstat import pyjstat
|
|
106
|
+
|
|
107
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/galicia.json'
|
|
108
|
+
|
|
109
|
+
# read from json-stat
|
|
110
|
+
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
|
|
111
|
+
|
|
112
|
+
# write to dataframe
|
|
113
|
+
df = dataset.write('dataframe')
|
|
114
|
+
print(df)
|
|
115
|
+
|
|
116
|
+
# read from dataframe
|
|
117
|
+
dataset_from_df = pyjstat.Dataset.read(df)
|
|
118
|
+
|
|
119
|
+
# write to json-stat
|
|
120
|
+
print(dataset_from_df.write())
|
|
121
|
+
|
|
122
|
+
Dataset operation: get_value
|
|
123
|
+
----------------------------------
|
|
124
|
+
|
|
125
|
+
This operation mimics the Javascript example in the JSON-stat web page::
|
|
126
|
+
|
|
127
|
+
from pyjstat import pyjstat
|
|
128
|
+
|
|
129
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/oecd.json'
|
|
130
|
+
query = [{'concept': 'UNR'}, {'area': 'US'}, {'year': '2010'}]
|
|
131
|
+
|
|
132
|
+
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
|
|
133
|
+
print(dataset.get_value(query))
|
|
134
|
+
|
|
135
|
+
Collection operations: read and write
|
|
136
|
+
-------------------------------------
|
|
137
|
+
|
|
138
|
+
A collection can be parsed into a list of dataframes::
|
|
139
|
+
|
|
140
|
+
from pyjstat import pyjstat
|
|
141
|
+
|
|
142
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/collection.json'
|
|
143
|
+
|
|
144
|
+
collection = pyjstat.Collection.read(EXAMPLE_URL)
|
|
145
|
+
df_list = collection.write('dataframe_list')
|
|
146
|
+
print(df_list)
|
|
147
|
+
|
|
148
|
+
Example with UK ONS API
|
|
149
|
+
-----------------------
|
|
150
|
+
|
|
151
|
+
In the following example, apikey parameter must be replaced by a real api key
|
|
152
|
+
from ONS. This dataset corresponds to residence type by sex by age in London::
|
|
153
|
+
|
|
154
|
+
EXAMPLE_URL = 'http://web.ons.gov.uk/ons/api/data/dataset/DC1104EW.json?'\
|
|
155
|
+
'context=Census&jsontype=json-stat&apikey=yourapikey&'\
|
|
156
|
+
'geog=2011HTWARDH&diff=&totals=false&'\
|
|
157
|
+
'dm/2011HTWARDH=E12000007'
|
|
158
|
+
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
|
|
159
|
+
df = dataset.write('dataframe')
|
|
160
|
+
print(df)
|
|
161
|
+
|
|
162
|
+
More examples
|
|
163
|
+
-------------
|
|
164
|
+
|
|
165
|
+
More examples can be found in the examples directory, both for versions 1.3
|
|
166
|
+
and 2.0.
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
Usage of version 0.3.5 and older (with support for JSON-stat 1.3)
|
|
170
|
+
=================================================================
|
|
171
|
+
|
|
172
|
+
This syntax is deprecated and therefore not recommended anymore.
|
|
173
|
+
|
|
174
|
+
From JSON-stat to pandas DataFrame
|
|
175
|
+
-----------------------------------
|
|
176
|
+
|
|
177
|
+
Typical usage often looks like this::
|
|
178
|
+
|
|
179
|
+
from pyjstat import pyjstat
|
|
180
|
+
import requests
|
|
181
|
+
from collections import OrderedDict
|
|
182
|
+
|
|
183
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/us-labor.json'
|
|
184
|
+
|
|
185
|
+
data = requests.get(EXAMPLE_URL)
|
|
186
|
+
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
|
|
187
|
+
print (results)
|
|
188
|
+
|
|
189
|
+
From pandas DataFrame to JSON-stat
|
|
190
|
+
----------------------------------
|
|
191
|
+
|
|
192
|
+
The same data can be converted into JSON-stat, with some unavoidable metadata
|
|
193
|
+
loss::
|
|
194
|
+
|
|
195
|
+
from pyjstat import pyjstat
|
|
196
|
+
import requests
|
|
197
|
+
from collections import OrderedDict
|
|
198
|
+
import json
|
|
199
|
+
|
|
200
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/us-labor.json'
|
|
201
|
+
|
|
202
|
+
data = requests.get(EXAMPLE_URL)
|
|
203
|
+
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
|
|
204
|
+
print (results)
|
|
205
|
+
print (json.dumps(json.loads(pyjstat.to_json_stat(results))))
|
|
206
|
+
|
|
207
|
+
Changes
|
|
208
|
+
-------
|
|
209
|
+
|
|
210
|
+
For a changes, fixes, improvements and new features reference, see CHANGES.txt.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
**LAST RELEASE 2.0**: update to 2.0 version is highly recommended, since it
|
|
2
|
+
supports JSON-stat 2.0 and brings other improvements. Also, Version 2.X starts
|
|
3
|
+
to **support Pandas 1.X, and won't have backwards compatibility**.
|
|
4
|
+
**WARNING**: support for Python 2.7 has been removed in pyjstat 2.0.
|
|
5
|
+
|
|
6
|
+
=======
|
|
7
|
+
pyjstat
|
|
8
|
+
=======
|
|
9
|
+
|
|
10
|
+
.. image:: https://travis-ci.org/predicador37/pyjstat.svg?branch=master
|
|
11
|
+
:target: https://travis-ci.org/predicador37/pyjstat
|
|
12
|
+
|
|
13
|
+
**pyjstat** is a python library for **JSON-stat** formatted data manipulation
|
|
14
|
+
which allows reading and writing JSON-stat [1]_ format with python,using the
|
|
15
|
+
DataFrame structures provided by the widely accepted pandas library [2]_.
|
|
16
|
+
The JSON-stat format is a simple lightweight JSON format for data
|
|
17
|
+
dissemination, currently in its 2.0 version.
|
|
18
|
+
Pyjstat is inspired in rjstat [3]_, a library to read and write
|
|
19
|
+
JSON-stat with R, by ajschumacher. Note that, like in the rjstat project,
|
|
20
|
+
not all features are supported (i.e. not all metadata are converted).
|
|
21
|
+
**pyjstat** is provided under the Apache License 2.0.
|
|
22
|
+
|
|
23
|
+
.. [1] http://json-stat.org/ for JSON-stat information
|
|
24
|
+
.. [2] http://pandas.pydata.org for Python Data Analysis Library information
|
|
25
|
+
.. [3] https://github.com/ajschumacher/rjstat for rjstat library information
|
|
26
|
+
|
|
27
|
+
This library was first developed to work with Python 2.7. With some fixes
|
|
28
|
+
(thanks to @andrekittredge), now it works with Python 3.4 too.
|
|
29
|
+
|
|
30
|
+
Support for JSON-stat 1.3 and 2.0 is provided. JSON-stat 1.3 methods are
|
|
31
|
+
deprecated now and shouldn't be used in the future, but backwards compatibility
|
|
32
|
+
has been preserved.
|
|
33
|
+
|
|
34
|
+
Pyjstat 1.0 is aimed for simplicity. JSON-stat classes have been replicated
|
|
35
|
+
(Dataset, Collection and Dimension) and provided with simple read() and write()
|
|
36
|
+
methods. Funcionality covers common use cases as having a URL or dataframe
|
|
37
|
+
as data sources.
|
|
38
|
+
|
|
39
|
+
Methods for retrieving the value of a particular cube cell are taken from the
|
|
40
|
+
JSON-stat Javascript sample code. Thanks to @badosa for this.
|
|
41
|
+
|
|
42
|
+
Also, version 1.0 makes use of the requests package internally, which should
|
|
43
|
+
make downloading of datasets easier.
|
|
44
|
+
|
|
45
|
+
Test coverage is 88% and Travis CI is used.
|
|
46
|
+
|
|
47
|
+
Finally, note that the new classes and methods are inspired by JSON-stat 2.0,
|
|
48
|
+
and hence, won't work with previous versions of JSON-stat. However, older
|
|
49
|
+
methods are still available incorporating bug fixes and performance
|
|
50
|
+
improvements.
|
|
51
|
+
|
|
52
|
+
Installation
|
|
53
|
+
============
|
|
54
|
+
|
|
55
|
+
pyjstat requires pandas package. For installation::
|
|
56
|
+
|
|
57
|
+
pip install pyjstat
|
|
58
|
+
|
|
59
|
+
Usage of version 1.0 and newer (with JSON-stat 2.0 support)
|
|
60
|
+
===========================================================
|
|
61
|
+
|
|
62
|
+
Dataset operations: read and write
|
|
63
|
+
----------------------------------
|
|
64
|
+
|
|
65
|
+
Typical usage often looks like this::
|
|
66
|
+
|
|
67
|
+
from pyjstat import pyjstat
|
|
68
|
+
|
|
69
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/galicia.json'
|
|
70
|
+
|
|
71
|
+
# read from json-stat
|
|
72
|
+
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
|
|
73
|
+
|
|
74
|
+
# write to dataframe
|
|
75
|
+
df = dataset.write('dataframe')
|
|
76
|
+
print(df)
|
|
77
|
+
|
|
78
|
+
# read from dataframe
|
|
79
|
+
dataset_from_df = pyjstat.Dataset.read(df)
|
|
80
|
+
|
|
81
|
+
# write to json-stat
|
|
82
|
+
print(dataset_from_df.write())
|
|
83
|
+
|
|
84
|
+
Dataset operation: get_value
|
|
85
|
+
----------------------------------
|
|
86
|
+
|
|
87
|
+
This operation mimics the Javascript example in the JSON-stat web page::
|
|
88
|
+
|
|
89
|
+
from pyjstat import pyjstat
|
|
90
|
+
|
|
91
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/oecd.json'
|
|
92
|
+
query = [{'concept': 'UNR'}, {'area': 'US'}, {'year': '2010'}]
|
|
93
|
+
|
|
94
|
+
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
|
|
95
|
+
print(dataset.get_value(query))
|
|
96
|
+
|
|
97
|
+
Collection operations: read and write
|
|
98
|
+
-------------------------------------
|
|
99
|
+
|
|
100
|
+
A collection can be parsed into a list of dataframes::
|
|
101
|
+
|
|
102
|
+
from pyjstat import pyjstat
|
|
103
|
+
|
|
104
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/collection.json'
|
|
105
|
+
|
|
106
|
+
collection = pyjstat.Collection.read(EXAMPLE_URL)
|
|
107
|
+
df_list = collection.write('dataframe_list')
|
|
108
|
+
print(df_list)
|
|
109
|
+
|
|
110
|
+
Example with UK ONS API
|
|
111
|
+
-----------------------
|
|
112
|
+
|
|
113
|
+
In the following example, apikey parameter must be replaced by a real api key
|
|
114
|
+
from ONS. This dataset corresponds to residence type by sex by age in London::
|
|
115
|
+
|
|
116
|
+
EXAMPLE_URL = 'http://web.ons.gov.uk/ons/api/data/dataset/DC1104EW.json?'\
|
|
117
|
+
'context=Census&jsontype=json-stat&apikey=yourapikey&'\
|
|
118
|
+
'geog=2011HTWARDH&diff=&totals=false&'\
|
|
119
|
+
'dm/2011HTWARDH=E12000007'
|
|
120
|
+
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
|
|
121
|
+
df = dataset.write('dataframe')
|
|
122
|
+
print(df)
|
|
123
|
+
|
|
124
|
+
More examples
|
|
125
|
+
-------------
|
|
126
|
+
|
|
127
|
+
More examples can be found in the examples directory, both for versions 1.3
|
|
128
|
+
and 2.0.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
Usage of version 0.3.5 and older (with support for JSON-stat 1.3)
|
|
132
|
+
=================================================================
|
|
133
|
+
|
|
134
|
+
This syntax is deprecated and therefore not recommended anymore.
|
|
135
|
+
|
|
136
|
+
From JSON-stat to pandas DataFrame
|
|
137
|
+
-----------------------------------
|
|
138
|
+
|
|
139
|
+
Typical usage often looks like this::
|
|
140
|
+
|
|
141
|
+
from pyjstat import pyjstat
|
|
142
|
+
import requests
|
|
143
|
+
from collections import OrderedDict
|
|
144
|
+
|
|
145
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/us-labor.json'
|
|
146
|
+
|
|
147
|
+
data = requests.get(EXAMPLE_URL)
|
|
148
|
+
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
|
|
149
|
+
print (results)
|
|
150
|
+
|
|
151
|
+
From pandas DataFrame to JSON-stat
|
|
152
|
+
----------------------------------
|
|
153
|
+
|
|
154
|
+
The same data can be converted into JSON-stat, with some unavoidable metadata
|
|
155
|
+
loss::
|
|
156
|
+
|
|
157
|
+
from pyjstat import pyjstat
|
|
158
|
+
import requests
|
|
159
|
+
from collections import OrderedDict
|
|
160
|
+
import json
|
|
161
|
+
|
|
162
|
+
EXAMPLE_URL = 'http://json-stat.org/samples/us-labor.json'
|
|
163
|
+
|
|
164
|
+
data = requests.get(EXAMPLE_URL)
|
|
165
|
+
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
|
|
166
|
+
print (results)
|
|
167
|
+
print (json.dumps(json.loads(pyjstat.to_json_stat(results))))
|
|
168
|
+
|
|
169
|
+
Changes
|
|
170
|
+
-------
|
|
171
|
+
|
|
172
|
+
For a changes, fixes, improvements and new features reference, see CHANGES.txt.
|