pandas aiohttp plugin
Adds the functions Series.aiohttp.get_text() and Series.aiohttp.get_json()
to pandas Series objects.
1. Usage Notes
Both get_text() and get_json() support the parameters limit:int=100 and
ssl:bool=True which limit concurrent connections and enable or disable SSL
verification, respectively. More features may be supported in the future.
2. Examples
The following examples assume that you are running in a Jupyter notebook.
If you are running in a regular python environment, you will need to use the
asyncio.run()function to run the code. See the last example.
2.1. Series.aiohttp.get_text()
import pandas as pd
import pandas_aiohttp
# The next line is only needed if you want to prevent your IDE from highlighting as "unused import"
assert pandas_aiohttp
post_urls = pd.Series([
"https://jsonplaceholder.typicode.com/posts/1",
"https://jsonplaceholder.typicode.com/posts/2",
])
data = await post_urls.aiohttp.get_text()
0 {\n "userId": 1,\n "id": 1,\n "title": "sun...
1 {\n "userId": 1,\n "id": 2,\n "title": "qui...
dtype: object
2.2. Series.aiohttp.get_json()
A more common usage pattern;
import pandas as pd
import pandas_aiohttp
# create an example data frame:
frame = pd.DataFrame(
columns=["A", "B"],
data =[
["XY",23],
["YZ", 34],
["ZX", 45]
]
)
# Build a series of urls from the dataframe columns,
# and assign to a new column named "data":
frame["data"] = await (
"https://httpbin.org/get"
+"?A="+frame["A"]
+"&B="+frame["B"].astype(str)
).aiohttp.get_json()
result
0 {'args': {'A': 'XY', 'B': '23'}, 'headers': {'...
1 {'args': {'A': 'YZ', 'B': '34'}, 'headers': {'...
2 {'args': {'A': 'ZX', 'B': '45'}, 'headers': {'...
dtype: object
2.3. Manual Async Runtime
If you are running in a regular python environment, you will need to use the
asyncio.run() function to run the code.
import pandas as pd
import pandas_aiohttp
import asyncio
post_urls = pd.Series([
"https://jsonplaceholder.typicode.com/posts/1",
"https://jsonplaceholder.typicode.com/posts/2",
])
async def main():
data = await post_urls.aiohttp.get_text()
print(data)
asyncio.run(main())
Metadata
Release files for pandas-aiohttp 0.1.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 |
|---|---|---|---|---|
| pandas_aiohttp-0.1.0.tar.gz | 3.9 kB | Without provenance | Details for pandas_aiohttp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandas_aiohttp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pandas_aiohttp-0.1.0-py3-none-any.whl |
Total release size: 7.3 kB
Release files / pandas_aiohttp-0.1.0.tar.gz
| Download URL | pandas_aiohttp-0.1.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45a6a7d2603061345b262fed70208cd3463567aa038da528c4c821d91fc00657
|
|
BLAKE2b-256 checksum How to use checksums |
0f30f19fe25bb7bceb7827d0300493a0cad014fe10e3ed8b7188c46440fe29b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.8
|
Release files / pandas_aiohttp-0.1.0-py3-none-any.whl
| Download URL | pandas_aiohttp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a27d35e1c7d7b345178a415d74bf5e045ea10547b9e49d52c332ee79b0112ffb
|
|
BLAKE2b-256 checksum How to use checksums |
a293ba064c13a899eea08dfa3840b4c1db99e2c63e07a3bdaba49ce8df946cee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.8
|
Security for pandas-aiohttp 0.1.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.