Dataframe have SKU column and it is str data type as well.
Dataframe have no problem to show SKU proper. For example, SKU 00729.
However, when I downloaded it the SKU become 729. 0 values disappear.
Any advice to fix it?
Here is some of my code.
st.markdown(‘# CES Price (View All)’)
# Execute the stored procedure
cursor.execute(“{CALL usp_ces_price_all}”)
# Fetch the results
result_set = cursor.fetchall()
columns = [column[0] for column in cursor.description]
data = [dict(zip(columns, row)) for row in result_set]
Ces_all_prices = pd.DataFrame(data)
Ces_all_prices = Ces_all_prices[['SKU','COO','CBM','FOB','OF_IL','OF_CA','TARIFF_RATE','LOADABILITY','LANDED_COST_IL','LANDED_COST_CA','LANDED_PRICE_IL','LANDED_PRICE_CA']]
# Converting Dataframe to CSV file
def convert_df(df):
return df.to_csv(index=False).encode('utf-8')
Ces_all_prices = convert_df(Ces_all_prices)
st.download_button(
"Export CES Price",
Ces_all_prices ,
f"CES_Price_Export.csv",
mime='text/csv', type = 'primary')