Package: tableschema-pandas
tableschema-pandas-pyGenerate and load Pandas data framesTable Schemadescriptors.Featuresimplementstableschema.StorageinterfaceContentsGetting StartedInstallationExampleDocumentationStorageContributingChangelogGetting StartedInstallationThe package use semantic versioning. It means that major versions  could include breaking changes. It's highly recommended to specifypackageversion range in yoursetup/requirementsfile e.g.package>=1.0,<2.0.$ pip install tableschema-pandasExampleCode examples in this readme requires Python 3.3+ interpreter. You could see even more example inexamplesdirectory.You can easily load resources from a data package as Pandas data frames by simply usingdatapackage.push_datapackagefunction:>>>importdatapackage>>>data_url='http://data.okfn.org/data/core/country-list/datapackage.json'>>>storage=datapackage.push_datapackage(data_url,'pandas')>>>storage.buckets['data___data']>>>type(storage['data___data'])<class'pandas.core.frame.DataFrame'>>>>storage['data___data'].head()NameCode0AfghanistanAF1ÅlandIslandsAX2AlbaniaAL3AlgeriaDZ4AmericanSamoaASAlso it is possible to pull your existing data frame into a data package:>>>datapackage.pull_datapackage('/tmp/datapackage.json','country_list','pandas',tables={...'data':storage['data___data'],...})StorageDocumentationThe whole public API of this package is described here and follows semantic versioning rules. Everyting outside of this readme are private API and could be changed without any notification on any new version.StoragePackage implementsTabular Storageinterface (see full documentation on the link):This driver provides an additional API:Storage(dataframes=[])dataframes (object[])- list of storage dataframesWe can get storage this way:>>>fromtableschema_pandasimportStorage>>>storage=Storage()Storage works as a container for Pandas data frames. You can define new data frame inside storage usingstorage.createmethod:>>>storage.create('data',{...'primaryKey':'id',...'fields':[...{'name':'id','type':'integer'},...{'name':'comment','type':'string'},...]...})>>>storage.buckets['data']>>>storage['data'].shape(0,0)Usestorage.writeto populate data frame with data:>>>storage.write('data',[(1,'a'),(2,'b')])>>>storage['data']idcomment1a2bAlso you can usetabulatorto populate data frame from external data file. As you see, subsequent writes simply appends new data on top of existing ones:>>>importtabulator>>>withtabulator.Stream('data/comments.csv',headers=1)asstream:...storage.write('data',stream)>>>storage['data']idcomment1a2b1goodContributingThe project follows theOpen Knowledge International coding standards.Recommended way to get started is to create and activate a project virtual environment.
To install package and development dependencies into active environment:$ make installTo run tests with linting and coverage:$maketestFor lintingpylamaconfigured inpylama.iniis used. On this stage it's already
installed into your environment and could be used separately with more fine-grained control
as described in documentation -https://pylama.readthedocs.io/en/latest/.For example to sort results by error type:$pylama--sort<path>For testingtoxconfigured intox.iniis used.
It's already installed into your environment and could be used separately with more fine-grained control as described in documentation -https://testrun.org/tox/latest/.For example to check subset of tests against Python 2 environment with increased verbosity.
All positional arguments and options after--will be passed topy.test:tox-epy27---vtests/<path>Under the hoodtoxusespytestconfigured inpytest.ini,coverageandmockpackages. This packages are available only in tox envionments.ChangelogHere described only breaking and the most important changes. The full changelog and documentation for all released versions could be found in nicely formattedcommit history.v1.1Added support for composite primary keys (loading to pandas)v1.0Initial driver implementation