I am creating a line chart to show frequency
and as you can see the ābraƧo 1ā is right next to ābraƧo 10ā and it should be ābraƧo 2ā and so on
def frequency(choices,allrewards):
st.write("### FrequĆŖncia de recompensas")
df = pd.DataFrame(allrewards).T
df.columns = [f"BraƧo {i+1}" for i in range(len(allrewards))]
df.index.name = "Execução"
st.line_chart(df)
#example of choices
[24, 12, 22, 23, 19]
#example of allRewards
[[3.123895227453449, 3.515965858835796, 4.171472032800911], [4.2779499849109595], [1.3887435377347015, 3.4967789928358304], [3.807072733441112], [3.728360638605822, 3.142179167264145, 5.329350022687842]]
Goyo
May 5, 2023, 10:40pm
2
That is how strings are sorted.
>>> l = [f"BraƧo {i+1}" for i in range(10)]
>>> l
['BraƧo 1', 'BraƧo 2', 'BraƧo 3', 'BraƧo 4', 'BraƧo 5', 'BraƧo 6', 'BraƧo 7', 'BraƧo 8', 'BraƧo 9', 'BraƧo 10']
>>> sorted(l)
['BraƧo 1', 'BraƧo 10', 'BraƧo 2', 'BraƧo 3', 'BraƧo 4', 'BraƧo 5', 'BraƧo 6', 'BraƧo 7', 'BraƧo 8', 'BraƧo 9']
How would I change it to sort like the first array? in the numeric way
Goyo
May 11, 2023, 6:26am
4
I donāt think you can do that with st.line_chart
. Probably you can use st.altair_chart
but then I donāt know much about altair
.
system
Closed
November 7, 2023, 6:27am
5
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.