Created
February 9, 2020 21:55
-
-
Save rchardptrsn/70a2be8e2ccfc3aeaa4f1ebb57c3edba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Initialize list | |
| dflist = [] | |
| # Connection link | |
| collection_link = database_link + '/colls/' + 'HDIcontainer' | |
| # Write out query | |
| query = 'SELECT * FROM c where c.country="Afghanistan" and c.level="National"' | |
| # For-loop to retrieve individual json records from Cosmos DB | |
| # that satisfy our query | |
| for item in client.QueryItems(collection_link, | |
| query, | |
| {'enableCrossPartitionQuery': True} | |
| ): | |
| # Append each item as a dictionary to list | |
| dflist.append(dict(item)) | |
| # Convert list to pandas DataFrame | |
| df = pd.DataFrame(dflist) | |
| df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment