Unlock the power of low-code data analysis in Python with generative AI! In this tutorial, you'll learn to query SQL data using Python, integrate OpenAI with your Jupyter Notebook, and streamline your data analysis process. Follow along as we set up PostgreSQL on AWS RDS, securely manage API keys, and leverage AI to explain and generate real-time code.
Data:
Download the demo notebook from https://github.com/xbwei/Social-Data-Analytics-in-the-Cloud-with-AI/blob/main/Analyze_Census_Data.ipynb.
Learn how to collect Census Data: https://www.lbsocial.net/post/step-by-step-guide-setting-up-postgresql-server-collecting-census-data-in-python-with-aws-rds
Steps:
Start the PostgreSQL instance on AWS RDS.
Store the OpenAI API Key in Secretes Manager
Secret name: openai
Key name: api_key
Start the Notebook Instance in SageMaker and upload the demo notebook.
Open the notebook and execute the cells:
Install the Python libraries and restart the kernel.
Pass credentials, connect to the PostgreSQL database, and load the OpenAI API Key
List the available AI models. If openAI is not in the AI mode list, execute this code:
pip install jupyter-ai[all]
Define a simple SQL and use pandas to visualize the data
Try to use the ai magic commands to explain the code or create new code
Close the connection and cursor
Use the Git command to upload the notebook to GitHub. Check the uploaded Notebook in GitHub.
Stop the Notebook and PostgreSQL instances.
Please note: OpenAI or any LLMs can access your data. Please check Data Privacy Policies or use a locally hosted LLM to process sensitive information.
Comments