starlette-dataframe-response
Convenient, but not fast.
Resources:
Installation
$ pip install starlette-dataframe-response
Requirements
Python 3.7+
Dependencies
- starlette
- pandas
- (vega_datasets)
- (magicalimport)
Example
import pandas as pd
from starlette.requests import Request
from starlette_dataframe_response import DataFrameResponse, guess_media_type
async def get_dataset(request: Request):
df: DataFrame = pd.read_csv("<some dataset>.csv")
return DataFrameResponse(df, media_type=guess_media_type(request))
app = Starlette(
debug=True,
routes=[
Route("/dataset/<some dataset>", get_dataset),
],
)
Then, supporting the request following.
# return dataset as json (orient=records)
GET /dataset/<some dataset>
# return dataset as csv
GET /dataset/<some dataset>?format=csv
# return dataset as markdown
GET /dataset/<some dataset>?format=markdown
# return dataset as html
GET /dataset/<some dataset>?format=html
If you want to customize the JSON response.
# use orient="columns"
DataFrameResponse(df, media_type=guess_media_type(request), to_json_orient="columns")
Or, if the response is created by DataFrameResponse.from_request(request, df), it is also OK.
$ use orient="columns"
GET /dataset/<some dataset>?to_json_orient=columns
python -m starlette_dataframe_response.distribute
And It also includes examples using vega-datasets.
$ python -m starlette_dataframe_response.distribute --port 8888
(with httpie)
$ http :8888/
$ http :8888/iris
$ http :8888/cars
$ http :8888/iris format==csv
$ http :8888/iris/columns
$ http :8888/iris/describe
$ http :8888/iris/groupby/species/aggs/sepalWidth
$ http :8888/iris/groupby/species/aggs/sepalWidth fn==min fn==max fn==count fn==mean fn==std
$ http :8888/iris/groupby/species/aggs/sepalWidth,sepalLength
Or if you want to see an example using a custom data, in above included app examples/01data-provider/
Contribution
Metadata
Release files for starlette-dataframe-response 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| starlette-dataframe-response-0.0.0.tar.gz | 5.6 kB | Without provenance | Details for starlette-dataframe-response-0.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| starlette_dataframe_response-0.0.0-py3-none-any.whl | Python 3 | none | any | Details for starlette_dataframe_response-0.0.0-py3-none-any.whl |
Total release size: 11.6 kB
Release files / starlette-dataframe-response-0.0.0.tar.gz
| Download URL | starlette-dataframe-response-0.0.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac422c3b0b611c449f191cb8cb8c5fc765be41668eb5f7394da18cf17cf57ca2
|
|
BLAKE2b-256 checksum How to use checksums |
2ed08f38d127202063caf3ed1c400cbb0c4f694cda7d0b4379ef90e5b1ead437
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.5
|
Release files / starlette_dataframe_response-0.0.0-py3-none-any.whl
| Download URL | starlette_dataframe_response-0.0.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bcfc481859728a915f1db0fe85f6624dc3c3c6e8181ba9e9df6b58107efd197d
|
|
BLAKE2b-256 checksum How to use checksums |
37e23531fdae8ae996bbf04818361ab38962d5dac4946c68a995106633f054c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.5
|
Security for starlette-dataframe-response 0.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.