Skip to content

Instantly share code, notes, and snippets.

@romicofre
Created June 28, 2020 01:03
Show Gist options
  • Select an option

  • Save romicofre/ee80100b62b5fdbed42218e8239df94e to your computer and use it in GitHub Desktop.

Select an option

Save romicofre/ee80100b62b5fdbed42218e8239df94e to your computer and use it in GitHub Desktop.
Load firestore table to pandas dataframe
import pandas as pd
from google.cloud import firestore
db = firestore.Client()
users = list(db.collection(u'users').stream())
users_dict = list(map(lambda x: x.to_dict(), users))
df = pd.DataFrame(users_dict)
@jaredfiacco2

Copy link
Copy Markdown

Thank you!

@dmi3coder

Copy link
Copy Markdown

Exactly what I was looking for, thank you!

@jpetro416

jpetro416 commented Jan 24, 2022 •

Copy link
Copy Markdown

Thanks! In my case I needed lowercase .client()

@brianwetzel

Copy link
Copy Markdown

perfect, thanks

@a01796238

Copy link
Copy Markdown

Thank you, and if I need to add the ID also?

@tonygaul-hd

tonygaul-hd commented Aug 19, 2025 •

Copy link
Copy Markdown

Thank you, and if I need to add the ID also?

users_dict = list(map(lambda x: {**x.to_dict(), 'id': x.id}, users))
df = pd.DataFrame(users_dict)
df.set_index('id', inplace=True)

optional if you want to convert index to column
df.reset_index()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment