pasting results into editable dataframe
hikmetc opened this issue · comments
Checklist
- I have searched the existing issues for similar feature requests.
- I added a descriptive title and summary to this issue.
Summary
I can copy and paste my results from excel spreadsheet into st.data_editor. However, when I try copy and pasting float values, st.data_editor delete the dots that separate decimals. I hope streamlit team find a solution for this.
Why?
I can copy and paste my results from excel spreadsheet into st.data_editor. However, when I try copy and pasting float values, st.data_editor delete the dots that separate decimals. I hope streamline team find a solution for this.
How?
No response
Additional Context
No response
Hey, do you have a code example of the data editor you're using? I think what might happen here is that you're pasting into an integer column and that's why decimals are getting cut off. You can turn an int column into a float column by either putting floats in it initially or by explicitly setting the step
parameter here.
here is my code example:
for i, table in enumerate(tables):
col1.markdown(f"###### **:blue[Candidate Method]**")
# Generate column configuration dynamically
column_config = {}
for replicate in range(1, number_of_replicates_candidate + 1):
column_name = f'Replicate {replicate}'
column_config[column_name] = st.column_config.NumberColumn(
column_name,
help=f"Candidate measurement result {column_name}",
min_value=0,
max_value=999999999999999999999999999999999999999,
format="%g",
)
# Display the edited DataFrame
edited_df = col1.data_editor(
table,
column_config=column_config,
key=1, # Pass a unique key to each data_editor
hide_index=False, # Show index column
num_rows="fixed"
)
edited_df = pd.DataFrame(edited_df)
# Comparative method
# Create empty DataFrames based on user inputs
tables2 = []
df2 = pd.DataFrame(index=range(1, number_of_samples + 1),
columns=[f'Replicate {replicate}' for replicate in range(1, number_of_replicates_comparative + 1)])
df2.index.name = 'Sample no.'
tables2.append(df2)
here is how the problem occurs:
Thanks for reporting. The issue here is that your excel is using ,
as decimal seperator while the dataframe expects a .
(,
is interpreted as thousand separator). I think we eventually will need to make this decision in the dataframe based on the browser locale, but that can cause other issues that needs investigation. We are planning to do a bigger project on localzation at some point and this is one of the aspects that we would want to include in this project.
Closing this issue since it is a overlapping with another issue form you from a year ago :) #7866