DEV Community


Discussion on: Turn a Pandas DataFrame into an API

emagianna profile image
Emanuel Giannattasio • Edited

Hi Eric...(First, Sorry for my English.)

I follow the example that I find on the git repo(, when I run it , i see this error :

await beneath.write_full(
Enter fullscreen mode Exit fullscreen mode

SyntaxError: 'await' outside function

Can you tell me if i do something wrong? Thanks in advance.

ericpgreen profile image
Eric P Green Author

Hey Emanuel,

Sorry about that! We'll add some info to the docs today to make this more clear. I know you figured it out, but I'll leave this comment here for others to find.

The keyword "await" declares an asyncio coroutine (described in depth here:, and there are a few options for running these:

  1. In a standard Python script, as you mentioned, you have to wrap each coroutine in an async function, and start the execution with This is a good resource:

  2. In a Jupyter notebook, which I was using for the blog post and the quick start, it's actually much easier. An asyncio context is automatically included, and you can directly run any await ... code block.

  3. You can spawn an asyncio-enabled Python REPL by running python -m asyncio in a command line. In this case too, you can directly run any await ... code block.

Let me know if anything else comes up and I'd be happy to help!

emagianna profile image
Emanuel Giannattasio • Edited

I resolve called beneath in this way :

import beneath
import asyncio
description="Daily commits to",

emagianna profile image
Emanuel Giannattasio

I guess, you need to update the doc...all beneath function must be called with

for example, to read a stream and load in pandas dataframe the code is the next:

df ="USERNAME/financial-reference-data/s-and-p-500-constituents"))

At last, this work for me. Regards Eric is a great solution Beneath, I will try to use it with streamlit.

begelundmuller profile image
Benjamin Egelund-Müller • Edited

Hey Emanuel (and anyone else following along here!),

I know await/async (asyncio) can be pretty confusing if you haven't used it before – it's perfectly normal to use Python without it, but we think it's such an awesome feature that we wanted to use it for Beneath.

To help explain it better, I added a new docs page to explain the what/how/why of it:

We want to keep the example snippets concise, but we'll try to link to this helper from the examples to avoid confusion :)

Thanks for the input!