streamlit-nightly 1.26.1.dev20230912__py2.py3-none-any.whl → 1.26.1.dev20230915__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/elements/dataframe_selector.py +139 -158
- streamlit/elements/pyplot.py +1 -1
- streamlit/elements/widgets/button.py +14 -1
- streamlit/elements/widgets/number_input.py +25 -18
- streamlit/elements/widgets/selectbox.py +4 -3
- streamlit/elements/widgets/text_widgets.py +172 -73
- streamlit/proto/NumberInput_pb2.py +4 -4
- streamlit/proto/TextArea_pb2.py +2 -2
- streamlit/proto/TextInput_pb2.py +4 -4
- streamlit/runtime/metrics_util.py +9 -0
- streamlit/runtime/state/__init__.py +0 -1
- streamlit/runtime/state/session_state.py +2 -2
- streamlit/runtime/state/widgets.py +0 -4
- streamlit/static/asset-manifest.json +8 -8
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/1451.76174eea.chunk.js +1 -0
- streamlit/static/static/js/{4436.0d12b4f4.chunk.js → 4436.9b8d7cb9.chunk.js} +1 -1
- streamlit/static/static/js/4666.29813cd1.chunk.js +1 -0
- streamlit/static/static/js/5379.acbf1a74.chunk.js +1 -0
- streamlit/static/static/js/7175.1af60fa9.chunk.js +1 -0
- streamlit/static/static/js/8691.9d96e187.chunk.js +1 -0
- streamlit/static/static/js/main.2ba402e0.js +2 -0
- streamlit/testing/element_tree.py +14 -12
- {streamlit_nightly-1.26.1.dev20230912.dist-info → streamlit_nightly-1.26.1.dev20230915.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.26.1.dev20230912.dist-info → streamlit_nightly-1.26.1.dev20230915.dist-info}/RECORD +30 -30
- streamlit/static/static/js/1451.20b10c89.chunk.js +0 -1
- streamlit/static/static/js/4666.fe4ef587.chunk.js +0 -1
- streamlit/static/static/js/5379.ed613f3a.chunk.js +0 -1
- streamlit/static/static/js/7175.2ddee0f1.chunk.js +0 -1
- streamlit/static/static/js/8691.593dd822.chunk.js +0 -1
- streamlit/static/static/js/main.f88db55d.js +0 -2
- /streamlit/static/static/js/{main.f88db55d.js.LICENSE.txt → main.2ba402e0.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.26.1.dev20230912.data → streamlit_nightly-1.26.1.dev20230915.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.26.1.dev20230912.dist-info → streamlit_nightly-1.26.1.dev20230915.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.26.1.dev20230912.dist-info → streamlit_nightly-1.26.1.dev20230915.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.26.1.dev20230912.dist-info → streamlit_nightly-1.26.1.dev20230915.dist-info}/top_level.txt +0 -0
@@ -115,10 +115,8 @@ class DataFrameSelectorMixin:
|
|
115
115
|
>>> import pandas as pd
|
116
116
|
>>> import numpy as np
|
117
117
|
>>>
|
118
|
-
>>> df = pd.DataFrame(
|
119
|
-
|
120
|
-
... columns=('col %d' % i for i in range(20)))
|
121
|
-
...
|
118
|
+
>>> df = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
|
119
|
+
>>>
|
122
120
|
>>> st.dataframe(df) # Same as st.write(df)
|
123
121
|
|
124
122
|
.. output::
|
@@ -132,10 +130,8 @@ class DataFrameSelectorMixin:
|
|
132
130
|
>>> import pandas as pd
|
133
131
|
>>> import numpy as np
|
134
132
|
>>>
|
135
|
-
>>> df = pd.DataFrame(
|
136
|
-
|
137
|
-
... columns=('col %d' % i for i in range(20)))
|
138
|
-
...
|
133
|
+
>>> df = pd.DataFrame(np.random.randn(10, 20), columns=("col %d" % i for i in range(20)))
|
134
|
+
>>>
|
139
135
|
>>> st.dataframe(df.style.highlight_max(axis=0))
|
140
136
|
|
141
137
|
.. output::
|
@@ -195,7 +191,7 @@ class DataFrameSelectorMixin:
|
|
195
191
|
def table(self, data: "Data" = None) -> "DeltaGenerator":
|
196
192
|
"""Display a static table.
|
197
193
|
|
198
|
-
This differs from
|
194
|
+
This differs from ``st.dataframe`` in that the table in this case is
|
199
195
|
static: its entire contents are laid out directly on the page.
|
200
196
|
|
201
197
|
Parameters
|
@@ -213,10 +209,8 @@ class DataFrameSelectorMixin:
|
|
213
209
|
>>> import pandas as pd
|
214
210
|
>>> import numpy as np
|
215
211
|
>>>
|
216
|
-
>>> df = pd.DataFrame(
|
217
|
-
|
218
|
-
... columns=('col %d' % i for i in range(5)))
|
219
|
-
...
|
212
|
+
>>> df = pd.DataFrame(np.random.randn(10, 5), columns=("col %d" % i for i in range(5)))
|
213
|
+
>>>
|
220
214
|
>>> st.table(df)
|
221
215
|
|
222
216
|
.. output::
|
@@ -243,13 +237,13 @@ class DataFrameSelectorMixin:
|
|
243
237
|
) -> "DeltaGenerator":
|
244
238
|
"""Display a line chart.
|
245
239
|
|
246
|
-
This is syntax-sugar around st.altair_chart
|
240
|
+
This is syntax-sugar around ``st.altair_chart``. The main difference
|
247
241
|
is this command uses the data's own column and indices to figure out
|
248
242
|
the chart's spec. As a result this is easier to use for many "just plot
|
249
243
|
this" scenarios, while being less customizable.
|
250
244
|
|
251
|
-
If st.line_chart does not guess the data specification
|
252
|
-
correctly, try specifying your desired chart using st.altair_chart
|
245
|
+
If ``st.line_chart`` does not guess the data specification
|
246
|
+
correctly, try specifying your desired chart using ``st.altair_chart``.
|
253
247
|
|
254
248
|
Parameters
|
255
249
|
----------
|
@@ -292,10 +286,10 @@ class DataFrameSelectorMixin:
|
|
292
286
|
formats above (hex string or color tuple), then that color will
|
293
287
|
be used.
|
294
288
|
|
295
|
-
For example: if the dataset has 1000 rows, but this column
|
296
|
-
|
297
|
-
|
298
|
-
|
289
|
+
For example: if the dataset has 1000 rows, but this column only
|
290
|
+
contains the values "adult", "child", and "baby", then those 1000
|
291
|
+
datapoints will be grouped into three lines whose colors will be
|
292
|
+
automatically selected from the default palette.
|
299
293
|
|
300
294
|
But, if for the same 1000-row dataset, this column contained
|
301
295
|
the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
|
@@ -324,15 +318,13 @@ class DataFrameSelectorMixin:
|
|
324
318
|
precedence over the width argument.
|
325
319
|
This argument can only be supplied by keyword.
|
326
320
|
|
327
|
-
|
328
|
-
|
321
|
+
Examples
|
322
|
+
--------
|
329
323
|
>>> import streamlit as st
|
330
324
|
>>> import pandas as pd
|
331
325
|
>>> import numpy as np
|
332
326
|
>>>
|
333
|
-
>>> chart_data = pd.DataFrame(
|
334
|
-
... np.random.randn(20, 3),
|
335
|
-
... columns=['a', 'b', 'c'])
|
327
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
|
336
328
|
>>>
|
337
329
|
>>> st.line_chart(chart_data)
|
338
330
|
|
@@ -348,18 +340,15 @@ class DataFrameSelectorMixin:
|
|
348
340
|
>>> import pandas as pd
|
349
341
|
>>> import numpy as np
|
350
342
|
>>>
|
351
|
-
>>> chart_data = pd.DataFrame(
|
352
|
-
...
|
353
|
-
...
|
354
|
-
...
|
355
|
-
...
|
356
|
-
|
357
|
-
>>> st.line_chart(
|
358
|
-
... chart_data,
|
359
|
-
... x='col1',
|
360
|
-
... y='col2',
|
361
|
-
... color='col3'
|
343
|
+
>>> chart_data = pd.DataFrame(
|
344
|
+
... {
|
345
|
+
... "col1": np.random.randn(20),
|
346
|
+
... "col2": np.random.randn(20),
|
347
|
+
... "col3": np.random.choice(["A", "B", "C"], 20),
|
348
|
+
... }
|
362
349
|
... )
|
350
|
+
>>>
|
351
|
+
>>> st.line_chart(chart_data, x="col1", y="col2", color="col3")
|
363
352
|
|
364
353
|
.. output::
|
365
354
|
https://doc-line-chart1.streamlit.app/
|
@@ -373,15 +362,10 @@ class DataFrameSelectorMixin:
|
|
373
362
|
>>> import pandas as pd
|
374
363
|
>>> import numpy as np
|
375
364
|
>>>
|
376
|
-
>>> chart_data = pd.DataFrame(
|
377
|
-
... np.random.randn(20, 3),
|
378
|
-
... columns = ['col1', 'col2', 'col3'])
|
365
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["col1", "col2", "col3"])
|
379
366
|
>>>
|
380
367
|
>>> st.line_chart(
|
381
|
-
...
|
382
|
-
... x='col1',
|
383
|
-
... y=['col2', 'col3'],
|
384
|
-
... color=['#FF0000', '#0000FF'] # Optional
|
368
|
+
... chart_data, x="col1", y=["col2", "col3"], color=["#FF0000", "#0000FF"] # Optional
|
385
369
|
... )
|
386
370
|
|
387
371
|
.. output::
|
@@ -421,13 +405,13 @@ class DataFrameSelectorMixin:
|
|
421
405
|
) -> "DeltaGenerator":
|
422
406
|
"""Display an area chart.
|
423
407
|
|
424
|
-
This is
|
408
|
+
This is syntax-sugar around ``st.altair_chart``. The main difference
|
425
409
|
is this command uses the data's own column and indices to figure out
|
426
410
|
the chart's spec. As a result this is easier to use for many "just plot
|
427
411
|
this" scenarios, while being less customizable.
|
428
412
|
|
429
|
-
If st.area_chart does not guess the data specification
|
430
|
-
correctly, try specifying your desired chart using st.altair_chart
|
413
|
+
If ``st.area_chart`` does not guess the data specification
|
414
|
+
correctly, try specifying your desired chart using ``st.altair_chart``.
|
431
415
|
|
432
416
|
Parameters
|
433
417
|
----------
|
@@ -470,10 +454,10 @@ class DataFrameSelectorMixin:
|
|
470
454
|
formats above (hex string or color tuple), then that color will
|
471
455
|
be used.
|
472
456
|
|
473
|
-
For example: if the dataset has 1000 rows, but this column
|
474
|
-
|
475
|
-
|
476
|
-
|
457
|
+
For example: if the dataset has 1000 rows, but this column only
|
458
|
+
contains the values "adult", "child", and "baby", then those 1000
|
459
|
+
datapoints will be grouped into three series whose colors will be
|
460
|
+
automatically selected from the default palette.
|
477
461
|
|
478
462
|
But, if for the same 1000-row dataset, this column contained
|
479
463
|
the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
|
@@ -502,15 +486,13 @@ class DataFrameSelectorMixin:
|
|
502
486
|
precedence over the width argument.
|
503
487
|
This argument can only be supplied by keyword.
|
504
488
|
|
505
|
-
|
506
|
-
|
489
|
+
Examples
|
490
|
+
--------
|
507
491
|
>>> import streamlit as st
|
508
492
|
>>> import pandas as pd
|
509
493
|
>>> import numpy as np
|
510
494
|
>>>
|
511
|
-
>>> chart_data = pd.DataFrame(
|
512
|
-
... np.random.randn(20, 3),
|
513
|
-
... columns = ['a', 'b', 'c'])
|
495
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
|
514
496
|
>>>
|
515
497
|
>>> st.area_chart(chart_data)
|
516
498
|
|
@@ -526,18 +508,15 @@ class DataFrameSelectorMixin:
|
|
526
508
|
>>> import pandas as pd
|
527
509
|
>>> import numpy as np
|
528
510
|
>>>
|
529
|
-
>>> chart_data = pd.DataFrame(
|
530
|
-
...
|
531
|
-
...
|
532
|
-
...
|
533
|
-
...
|
534
|
-
|
535
|
-
>>> st.area_chart(
|
536
|
-
... chart_data,
|
537
|
-
... x='col1',
|
538
|
-
... y='col2',
|
539
|
-
... color='col3'
|
511
|
+
>>> chart_data = pd.DataFrame(
|
512
|
+
... {
|
513
|
+
... "col1": np.random.randn(20),
|
514
|
+
... "col2": np.random.randn(20),
|
515
|
+
... "col3": np.random.choice(["A", "B", "C"], 20),
|
516
|
+
... }
|
540
517
|
... )
|
518
|
+
>>>
|
519
|
+
>>> st.area_chart(chart_data, x="col1", y="col2", color="col3")
|
541
520
|
|
542
521
|
.. output::
|
543
522
|
https://doc-area-chart1.streamlit.app/
|
@@ -551,15 +530,10 @@ class DataFrameSelectorMixin:
|
|
551
530
|
>>> import pandas as pd
|
552
531
|
>>> import numpy as np
|
553
532
|
>>>
|
554
|
-
>>> chart_data = pd.DataFrame(
|
555
|
-
|
556
|
-
... columns=['col1', 'col2', 'col3'])
|
557
|
-
...
|
533
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["col1", "col2", "col3"])
|
534
|
+
>>>
|
558
535
|
>>> st.area_chart(
|
559
|
-
...
|
560
|
-
... x='col1',
|
561
|
-
... y=['col2', 'col3'],
|
562
|
-
... color=['#FF0000','#0000FF'] # Optional
|
536
|
+
... chart_data, x="col1", y=["col2", "col3"], color=["#FF0000", "#0000FF"] # Optional
|
563
537
|
... )
|
564
538
|
|
565
539
|
.. output::
|
@@ -599,13 +573,13 @@ class DataFrameSelectorMixin:
|
|
599
573
|
) -> "DeltaGenerator":
|
600
574
|
"""Display a bar chart.
|
601
575
|
|
602
|
-
This is
|
576
|
+
This is syntax-sugar around ``st.altair_chart``. The main difference
|
603
577
|
is this command uses the data's own column and indices to figure out
|
604
578
|
the chart's spec. As a result this is easier to use for many "just plot
|
605
579
|
this" scenarios, while being less customizable.
|
606
580
|
|
607
|
-
If st.bar_chart does not guess the data specification
|
608
|
-
correctly, try specifying your desired chart using st.altair_chart
|
581
|
+
If ``st.bar_chart`` does not guess the data specification
|
582
|
+
correctly, try specifying your desired chart using ``st.altair_chart``.
|
609
583
|
|
610
584
|
Parameters
|
611
585
|
----------
|
@@ -630,7 +604,7 @@ class DataFrameSelectorMixin:
|
|
630
604
|
The color to use for different series in this chart. This argument
|
631
605
|
can only be supplied by keyword.
|
632
606
|
|
633
|
-
For a bar chart with just
|
607
|
+
For a bar chart with just one series, this can be:
|
634
608
|
|
635
609
|
* None, to use the default color.
|
636
610
|
* A hex string like "#ffaa00" or "#ffaa0088".
|
@@ -648,10 +622,10 @@ class DataFrameSelectorMixin:
|
|
648
622
|
formats above (hex string or color tuple), then that color will
|
649
623
|
be used.
|
650
624
|
|
651
|
-
For example: if the dataset has 1000 rows, but this column
|
652
|
-
|
653
|
-
|
654
|
-
|
625
|
+
For example: if the dataset has 1000 rows, but this column only
|
626
|
+
contains the values "adult", "child", and "baby", then those 1000
|
627
|
+
datapoints will be grouped into three series whose colors will be
|
628
|
+
automatically selected from the default palette.
|
655
629
|
|
656
630
|
But, if for the same 1000-row dataset, this column contained
|
657
631
|
the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
|
@@ -680,16 +654,14 @@ class DataFrameSelectorMixin:
|
|
680
654
|
precedence over the width argument.
|
681
655
|
This argument can only be supplied by keyword.
|
682
656
|
|
683
|
-
|
684
|
-
|
657
|
+
Examples
|
658
|
+
--------
|
685
659
|
>>> import streamlit as st
|
686
660
|
>>> import pandas as pd
|
687
661
|
>>> import numpy as np
|
688
662
|
>>>
|
689
|
-
>>> chart_data = pd.DataFrame(
|
690
|
-
|
691
|
-
... columns=["a", "b", "c"])
|
692
|
-
...
|
663
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
|
664
|
+
>>>
|
693
665
|
>>> st.bar_chart(chart_data)
|
694
666
|
|
695
667
|
.. output::
|
@@ -704,18 +676,15 @@ class DataFrameSelectorMixin:
|
|
704
676
|
>>> import pandas as pd
|
705
677
|
>>> import numpy as np
|
706
678
|
>>>
|
707
|
-
>>> chart_data = pd.DataFrame(
|
708
|
-
...
|
709
|
-
...
|
710
|
-
...
|
711
|
-
...
|
712
|
-
|
713
|
-
>>> st.bar_chart(
|
714
|
-
... chart_data,
|
715
|
-
... x='col1',
|
716
|
-
... y='col2',
|
717
|
-
... color='col3'
|
679
|
+
>>> chart_data = pd.DataFrame(
|
680
|
+
... {
|
681
|
+
... "col1": list(range(20)) * 3,
|
682
|
+
... "col2": np.random.randn(60),
|
683
|
+
... "col3": ["A"] * 20 + ["B"] * 20 + ["C"] * 20,
|
684
|
+
... }
|
718
685
|
... )
|
686
|
+
>>>
|
687
|
+
>>> st.bar_chart(chart_data, x="col1", y="col2", color="col3")
|
719
688
|
|
720
689
|
.. output::
|
721
690
|
https://doc-bar-chart1.streamlit.app/
|
@@ -730,14 +699,11 @@ class DataFrameSelectorMixin:
|
|
730
699
|
>>> import numpy as np
|
731
700
|
>>>
|
732
701
|
>>> chart_data = pd.DataFrame(
|
733
|
-
...
|
734
|
-
...
|
735
|
-
|
702
|
+
... {"col1": list(range(20)), "col2": np.random.randn(20), "col3": np.random.randn(20)}
|
703
|
+
... )
|
704
|
+
>>>
|
736
705
|
>>> st.bar_chart(
|
737
|
-
...
|
738
|
-
... x='col1',
|
739
|
-
... y=['col2', 'col3'],
|
740
|
-
... color=['#FF0000','#0000FF'] # Optional
|
706
|
+
... chart_data, x="col1", y=["col2", "col3"], color=["#FF0000", "#0000FF"] # Optional
|
741
707
|
... )
|
742
708
|
|
743
709
|
.. output::
|
@@ -779,22 +745,22 @@ class DataFrameSelectorMixin:
|
|
779
745
|
) -> "DeltaGenerator":
|
780
746
|
"""Display a scatterplot chart.
|
781
747
|
|
782
|
-
This is syntax-sugar around st.altair_chart
|
748
|
+
This is syntax-sugar around ``st.altair_chart``. The main difference
|
783
749
|
is this command uses the data's own column and indices to figure out
|
784
750
|
the chart's spec. As a result this is easier to use for many "just plot
|
785
751
|
this" scenarios, while being less customizable.
|
786
752
|
|
787
|
-
If st.scatter_chart does not guess the data specification correctly,
|
788
|
-
try specifying your desired chart using st.altair_chart
|
753
|
+
If ``st.scatter_chart`` does not guess the data specification correctly,
|
754
|
+
try specifying your desired chart using ``st.altair_chart``.
|
789
755
|
|
790
756
|
Parameters
|
791
757
|
----------
|
792
758
|
data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, snowflake.snowpark.table.Table, Iterable, dict or None
|
793
759
|
Data to be plotted.
|
794
760
|
Pyarrow tables are not supported by Streamlit's legacy DataFrame serialization
|
795
|
-
(i.e. with
|
761
|
+
(i.e. with ``config.dataFrameSerialization = "legacy"``).
|
796
762
|
To use pyarrow tables, please enable pyarrow by changing the config setting,
|
797
|
-
|
763
|
+
``config.dataFrameSerialization = "arrow"``.
|
798
764
|
|
799
765
|
x : str or None
|
800
766
|
Column name to use for the x-axis. If None, uses the data index for the x-axis.
|
@@ -814,7 +780,7 @@ class DataFrameSelectorMixin:
|
|
814
780
|
|
815
781
|
* None, to use the default color.
|
816
782
|
* A hex string like "#ffaa00" or "#ffaa0088".
|
817
|
-
* An RGB or RGBA tuple with the red, green,
|
783
|
+
* An RGB or RGBA tuple with the red, green, blue, and alpha
|
818
784
|
components specified as ints from 0 to 255 or floats from 0.0 to
|
819
785
|
1.0.
|
820
786
|
* The name of a column in the dataset where the color of that
|
@@ -826,9 +792,9 @@ class DataFrameSelectorMixin:
|
|
826
792
|
Otherwise, the color will be automatically picked from the
|
827
793
|
default palette.
|
828
794
|
|
829
|
-
For example: if the dataset has 1000 rows, but this column
|
830
|
-
|
831
|
-
|
795
|
+
For example: if the dataset has 1000 rows, but this column only
|
796
|
+
contains the values "adult", "child", and "baby", then those 1000
|
797
|
+
datapoints be shown using three colors from the default palette.
|
832
798
|
|
833
799
|
But if this column only contains floats or ints, then those
|
834
800
|
1000 datapoints will be shown using a colors from a continuous
|
@@ -843,10 +809,8 @@ class DataFrameSelectorMixin:
|
|
843
809
|
|
844
810
|
* A list of string colors or color tuples to be used for each of
|
845
811
|
the series in the chart. This list should have the same length
|
846
|
-
as the number of y values.
|
847
|
-
|
848
|
-
For example, for a chart with have 3 series this argument can
|
849
|
-
be set to ``color=["#fd0", "#f0f", "#04f"]``.
|
812
|
+
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
|
813
|
+
for three series).
|
850
814
|
|
851
815
|
size : str, float, or None
|
852
816
|
The size of the circles representing each point. This argument can
|
@@ -872,38 +836,53 @@ class DataFrameSelectorMixin:
|
|
872
836
|
precedence over the width argument.
|
873
837
|
This argument can only be supplied by keyword.
|
874
838
|
|
875
|
-
|
876
|
-
|
839
|
+
Examples
|
840
|
+
--------
|
877
841
|
>>> import streamlit as st
|
878
842
|
>>> import pandas as pd
|
879
843
|
>>> import numpy as np
|
880
844
|
>>>
|
881
|
-
>>> chart_data = pd.DataFrame(
|
882
|
-
|
883
|
-
... columns=['a', 'b', 'c'])
|
884
|
-
...
|
845
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
|
846
|
+
>>>
|
885
847
|
>>> st.scatter_chart(chart_data)
|
886
848
|
|
849
|
+
.. output::
|
850
|
+
https://doc-scatter-chart.streamlit.app/
|
851
|
+
height: 440px
|
852
|
+
|
887
853
|
You can also choose different columns to use for x and y, as well as set
|
888
854
|
the color dynamically based on a 3rd column (assuming your dataframe is in
|
889
855
|
long format):
|
890
856
|
|
891
|
-
>>>
|
892
|
-
|
893
|
-
|
894
|
-
|
857
|
+
>>> import streamlit as st
|
858
|
+
>>> import pandas as pd
|
859
|
+
>>> import numpy as np
|
860
|
+
>>>
|
861
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["col1", "col2", "col3"])
|
862
|
+
>>> chart_data['col4'] = np.random.choice(['A','B','C'], 20)
|
863
|
+
>>>
|
895
864
|
>>> st.scatter_chart(
|
896
865
|
... chart_data,
|
897
866
|
... x='col1',
|
898
867
|
... y='col2',
|
899
|
-
... color='
|
900
|
-
... size='
|
868
|
+
... color='col4',
|
869
|
+
... size='col3',
|
901
870
|
... )
|
902
871
|
|
872
|
+
.. output::
|
873
|
+
https://doc-scatter-chart1.streamlit.app/
|
874
|
+
height: 440px
|
875
|
+
|
903
876
|
Finally, if your dataframe is in wide format, you can group multiple
|
904
877
|
columns under the y argument to show multiple series with different
|
905
878
|
colors:
|
906
879
|
|
880
|
+
>>> import streamlit as st
|
881
|
+
>>> import pandas as pd
|
882
|
+
>>> import numpy as np
|
883
|
+
>>>
|
884
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 4), columns=["col1", "col2", "col3", "col4"])
|
885
|
+
>>>
|
907
886
|
>>> st.scatter_chart(
|
908
887
|
... chart_data,
|
909
888
|
... x='col1',
|
@@ -912,6 +891,10 @@ class DataFrameSelectorMixin:
|
|
912
891
|
... color=['#FF0000', '#0000FF'], # Optional
|
913
892
|
... )
|
914
893
|
|
894
|
+
.. output::
|
895
|
+
https://doc-scatter-chart2.streamlit.app/
|
896
|
+
height: 440px
|
897
|
+
|
915
898
|
"""
|
916
899
|
if _use_arrow():
|
917
900
|
return self.dg._arrow_scatter_chart(
|
@@ -945,7 +928,7 @@ class DataFrameSelectorMixin:
|
|
945
928
|
|
946
929
|
use_container_width : bool
|
947
930
|
If True, set the chart width to the column width. This takes
|
948
|
-
precedence over Altair's native
|
931
|
+
precedence over Altair's native ``width`` value.
|
949
932
|
|
950
933
|
theme : "streamlit" or None
|
951
934
|
The theme of the chart. Currently, we only support "streamlit" for the Streamlit
|
@@ -959,12 +942,13 @@ class DataFrameSelectorMixin:
|
|
959
942
|
>>> import numpy as np
|
960
943
|
>>> import altair as alt
|
961
944
|
>>>
|
962
|
-
>>> chart_data = pd.DataFrame(
|
963
|
-
|
964
|
-
|
965
|
-
...
|
966
|
-
|
967
|
-
...
|
945
|
+
>>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
|
946
|
+
>>>
|
947
|
+
>>> c = (
|
948
|
+
... alt.Chart(chart_data)
|
949
|
+
... .mark_circle()
|
950
|
+
... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
|
951
|
+
... )
|
968
952
|
>>>
|
969
953
|
>>> st.altair_chart(c, use_container_width=True)
|
970
954
|
|
@@ -1025,19 +1009,20 @@ class DataFrameSelectorMixin:
|
|
1025
1009
|
>>> import pandas as pd
|
1026
1010
|
>>> import numpy as np
|
1027
1011
|
>>>
|
1028
|
-
>>> chart_data = pd.DataFrame(
|
1029
|
-
... np.random.randn(200, 3),
|
1030
|
-
... columns=['a', 'b', 'c'])
|
1012
|
+
>>> chart_data = pd.DataFrame(np.random.randn(200, 3), columns=["a", "b", "c"])
|
1031
1013
|
>>>
|
1032
|
-
>>> st.vega_lite_chart(
|
1033
|
-
...
|
1034
|
-
...
|
1035
|
-
...
|
1036
|
-
...
|
1037
|
-
...
|
1038
|
-
...
|
1039
|
-
...
|
1040
|
-
... }
|
1014
|
+
>>> st.vega_lite_chart(
|
1015
|
+
... chart_data,
|
1016
|
+
... {
|
1017
|
+
... "mark": {"type": "circle", "tooltip": True},
|
1018
|
+
... "encoding": {
|
1019
|
+
... "x": {"field": "a", "type": "quantitative"},
|
1020
|
+
... "y": {"field": "b", "type": "quantitative"},
|
1021
|
+
... "size": {"field": "c", "type": "quantitative"},
|
1022
|
+
... "color": {"field": "c", "type": "quantitative"},
|
1023
|
+
... },
|
1024
|
+
... },
|
1025
|
+
... )
|
1041
1026
|
|
1042
1027
|
.. output::
|
1043
1028
|
https://doc-vega-lite-chart.streamlit.app/
|
@@ -1080,16 +1065,12 @@ class DataFrameSelectorMixin:
|
|
1080
1065
|
>>> import pandas as pd
|
1081
1066
|
>>> import numpy as np
|
1082
1067
|
>>>
|
1083
|
-
>>> df1 = pd.DataFrame(
|
1084
|
-
|
1085
|
-
... columns=('col %d' % i for i in range(20)))
|
1086
|
-
...
|
1068
|
+
>>> df1 = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
|
1069
|
+
>>>
|
1087
1070
|
>>> my_table = st.table(df1)
|
1088
1071
|
>>>
|
1089
|
-
>>> df2 = pd.DataFrame(
|
1090
|
-
|
1091
|
-
... columns=('col %d' % i for i in range(20)))
|
1092
|
-
...
|
1072
|
+
>>> df2 = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
|
1073
|
+
>>>
|
1093
1074
|
>>> my_table.add_rows(df2)
|
1094
1075
|
>>> # Now the table shown in the Streamlit app contains the data for
|
1095
1076
|
>>> # df1 followed by the data for df2.
|
streamlit/elements/pyplot.py
CHANGED
@@ -144,7 +144,7 @@ def marshall(
|
|
144
144
|
if clear_figure is None:
|
145
145
|
clear_figure = True
|
146
146
|
|
147
|
-
fig = plt
|
147
|
+
fig = cast("Figure", plt)
|
148
148
|
|
149
149
|
# Normally, dpi is set to 'figure', and the figure's dpi is set to 100.
|
150
150
|
# So here we pick double of that to make things look good in a high
|
@@ -351,6 +351,9 @@ class ButtonMixin:
|
|
351
351
|
) -> "DeltaGenerator":
|
352
352
|
r"""Display a link button element.
|
353
353
|
|
354
|
+
When clicked, a new tab will be opened to the specified URL. This will
|
355
|
+
create a new session for the user if directed within the app.
|
356
|
+
|
354
357
|
Parameters
|
355
358
|
----------
|
356
359
|
label : str
|
@@ -389,6 +392,17 @@ class ButtonMixin:
|
|
389
392
|
True. The default is False.
|
390
393
|
use_container_width: bool
|
391
394
|
An optional boolean, which makes the button stretch its width to match the parent container.
|
395
|
+
|
396
|
+
Example
|
397
|
+
-------
|
398
|
+
>>> import streamlit as st
|
399
|
+
>>>
|
400
|
+
>>> st.link_button("Go to gallery", "https://streamlit.io/gallery")
|
401
|
+
|
402
|
+
.. output::
|
403
|
+
https://doc-link-button.streamlit.app/
|
404
|
+
height: 200px
|
405
|
+
|
392
406
|
"""
|
393
407
|
# Checks whether the entered button type is one of the allowed options - either "primary" or "secondary"
|
394
408
|
if type not in ["primary", "secondary"]:
|
@@ -430,7 +444,6 @@ class ButtonMixin:
|
|
430
444
|
"download_button",
|
431
445
|
user_key=key,
|
432
446
|
label=label,
|
433
|
-
data=str(data),
|
434
447
|
file_name=file_name,
|
435
448
|
mime=mime,
|
436
449
|
key=key,
|