I have been rendered useless by Pandas Dataframes and formatting numbers

I have been struggling for months to get the Distribution Net column formatted as $$$ and I’ve failed at every attempt. It this a streamlit thing? Pandas thing?

Here’s the code:

query = 'SELECT Investor_Id, LastName, Distribution_Date, Distribution_Year, ’
'Distribution_quarter, Distribution_Net ,Investment from ’
'Distribution, Investors ’
‘where Investors.InvestorID = Distribution.Investor_Id’

st.title(‘BDK Services Group’)

df: DataFrame = pd.read_sql(query, mydb)

pd.options.display.float_format = ‘${:,.3f}’.format

nameList = df[‘LastName’].drop_duplicates()
yearList = df[‘Distribution_Year’].drop_duplicates()
quarterList = df[‘Distribution_quarter’].drop_duplicates().sort_values()
investmentList = df[‘Investment’].drop_duplicates()

FilterInvestment = st.sidebar.multiselect(“Investment”, investmentList)
FilterLastName = st.sidebar.selectbox(“LastName”, nameList)
FilterYear = st.sidebar.multiselect(“Distribution_Year”, yearList)
FilterQuarter = st.sidebar.multiselect(“Distribution_quarter”, quarterList)

print("Year : ", FilterYear)
print("Quarter : ", FilterQuarter)
print("Name : ", FilterLastName)
print("Investment : ", FilterInvestment)

filtered_df = df.loc[df[‘Investment’].isin(FilterInvestment) & (df[‘LastName’] == FilterLastName)]

styled_df = filtered_df.style.format({
‘Net’: ‘${:20,.0f}’, # Format as dollar amount with two decimal places
‘Year’: lambda x: f"{x:.0f}" # Remove commas from years (treated as float/int)

Here are the results:

Make sure you are formatting the column you want to format.

How does the format statement work in related to the dataframe?

Is it one-one relatively?

Not really sure what you are asking. If you are passing a dict, it should have a formatter for each column you want to format.

Why the code I posted doesn’t properly format the dataframe?

What needs to be done to accomplish what i need as per the original post

Because you are formatting columns "Year" and "Net", but there are no such columns in the data, so it has no effect. You probably want to format "Distribution_Net" instead.