I think you’re already doing the right thing! Pulling a CSV file out of a database and then loading it into Pandas in four lines of Python isn’t bad going.
If you really want to, you can trim a couple of lines by using BytesIO
rather than StringIO
. I’d do something like:
my_media=app_tables.my_table.get(...)['media_column']
df = pd.read_csv(io.BytesIO(media.get_bytes()), ...)
I think two lines is plenty concise