Newbie Bar Chart question


I want to do a simple POC for my team with a bar chart. I can write my SQL results to a table, but I want to see them in a Bar Chart but it displays nothing because of my bad syntax.

Code snippet:

df = pd.DataFrame(SQL_Query , columns=['reg','created_at'])
st.bar_chart(df, x='reg', y='created_at')

The table from st.write shows exactly what I want, only those 2 columns. The bar chart shows nothing.
Google has not been my friend! But I am sure this community can point me in the right direction!

Unfortunately we don’t know what SQL_Query is so I don’t think we can tell what is going wrong.

select sum(registrant_id) as reg, created_at::date from domo_dev.lk_training.registrants group by created_at::date order by 2 limit 100’

As mentioned above, ‘st.write(SQL_Query)’ displays the results as a table
first column looks like a row number, second is ‘reg’ and third is that created at date.

Sorry for not including the SQL the first time around!

If you add st.dataframe(df) below, does that show you the same as st.table(SQL_Query) ?

When I add ‘st.dataframe(df)’ I get a table filled with ‘None’ instead of the query results!

My guess is that those column names are not recognized. What do you get when you build the dataframe just as df = pd.DataFrame(SQL_Query) ? Does st.dataframe(df) shows a non-empty table that way?

Perhaps you should be using pd.read_sql_query instead.

When I try ‘df = pd.DataFrame(SQL_Query)’, then I see the correct results in my table.
Then I get this error:
streamlit.errors.StreamlitAPIException: reg (x parameter) was not found in the data columns or keys

UPDATE - I needed to capitalize the column names to match the table!
It works, thank you for the assistance !!!