You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/px-arguments.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,11 @@ jupyter:
33
33
thumbnail: thumbnail/plotly-express.png
34
34
---
35
35
36
-
Plotly Express (`px`) is the high-level interface to Plotly and provides functions for generating charts. `px` functions support data provided in a number of different formats (long, wide, and mixed) and as different types of objects, including pandas and Polars DataFrames.
36
+
Plotly Express (`px`) is the high-level interface to Plotly and provides functions for generating charts. `px` functions support data provided in a number of different formats (long, wide, and mixed) and as different types of objects, including pandas and Polars dataframes.
37
37
38
38
## Data for the Examples
39
39
40
-
The examples on this page use datasets available in the `data` package in `px`. `px.data` contains functions that when called return a dataset as a DataFrame. Some of the datasets included in `px.data` are:
40
+
The examples on this page use datasets available in the `data` package in `px`. `px.data` contains functions that when called return a dataset as a dataframe. Some of the datasets included in `px.data` are:
41
41
42
42
-`carshare` - Each row represents the availability of car-sharing services near the centroid of a zone in Montreal over a month-long period.
43
43
-`election` - Each row represents voting results for an electoral district in the 2013 Montreal mayoral election.
@@ -52,7 +52,7 @@ df = px.data.iris()
52
52
df.head()
53
53
```
54
54
55
-
By default `px.data` functions return Pandas DataFrames, but you can specify an alternative DataFrame type using `return_type`. `pandas`, `polars`, and `pyarrow` are supported return types.
55
+
By default `px.data` functions return a pandas `DataFrame` object, but you can specify an alternative dataframe type using `return_type`. `pandas`, `polars`, and `pyarrow` are supported return types.
56
56
57
57
```python
58
58
df = px.data.iris(return_type='polars')
@@ -115,13 +115,13 @@ fig.show()
115
115
Many more examples of wide-form and messy data input can be found in our [detailed wide-form support documentation](/python/wide-form/).
116
116
117
117
118
-
## DataFrame Input
118
+
## Dataframe Input
119
119
120
-
The first argument of every `px` function is `data_frame`. If you provide a DataFrame as a `px` function's first argument, you can then specify column names as strings from the DataFrame as other arguments.
120
+
The first argument of every `px` function is `data_frame`. If you provide a dataframe as a `px` function's first argument, you can then specify column names as strings from the dataframe as other arguments.
121
121
122
-
### Supported DataFrames
122
+
### Supported Dataframes
123
123
124
-
`px` functions natively support the following types of DataFrames:
124
+
`px` functions natively support the following types of dataframes:
125
125
126
126
- pandas
127
127
- Polars
@@ -131,13 +131,13 @@ The first argument of every `px` function is `data_frame`. If you provide a Data
131
131
> To use Polars, PyArrow, or Modin with Plotly Express, you'll need to have NumPy installed. You can install it with: `pip install numpy`.
132
132
To use [trendlines](/python/linear-fits/), you'll also need to have pandas installed.
133
133
134
-
`px` uses [Narwhals](https://narwhals-dev.github.io/narwhals/) to natively support these DataFrames. Other types of DataFrames that are currently supported by Narwhals may also work with `px`, for example cuDF.
134
+
`px` uses [Narwhals](https://narwhals-dev.github.io/narwhals/) to natively support these dataframes. Other types of dataframes that are currently supported by Narwhals may also work with `px`, for example cuDF.
135
135
136
-
You can also pass DataFrames that are not natively supported, but support the dataframe interchange protocol, or have a `to_pandas()` method.
136
+
You can also pass dataframes that are not natively supported, but support the [dataframe interchange protocol](https://data-apis.org/dataframe-protocol/latest/), or have a `to_pandas()` method.
137
137
138
138
### Example: Using a Pandas DataFrame with `px.bar`
139
139
140
-
Here, we create a pandas DataFrame, pass it to `px.bar` as its first argument, and then use the `"sepal_length"` column for the x-axis and the `"sepal_width"` for the y-axis.
140
+
Here, we create a pandas `DataFrame`, pass it to `px.bar` as its first argument, and then use the `"sepal_length"` column for the x-axis and the `"sepal_width"` for the y-axis.
141
141
142
142
```python
143
143
import plotly.express as px
@@ -150,7 +150,7 @@ fig.show()
150
150
151
151
### Example: Polars DataFrame with `px.bar`
152
152
153
-
`px` provides native support for DataFrame types other than pandas:
153
+
`px` provides native support for dataframe types other than pandas, including Polars:
If the DataFrame you are using has an index, it is also possible to use that index as an argument. In the following example, the index is used for the hover data.
166
+
If the dataframe you are using has an index, it is also possible to use that index as an argument. In the following example, the index is used for the hover data.
You can also use columns from multiple dataframes in one `px` function, as long as all the DataFrame columns you use have the same length. In this example, we pass `df1` as the `data_frame` argument to `px.bar` and then us a column from `df2` for the `y` argument.
178
+
You can also use columns from multiple dataframes in one `px` function, as long as all the dataframe columns you use have the same length. In this example, we pass `df1` as the `data_frame` argument to `px.bar` and then us a column from `df2` for the `y` argument.
179
179
180
180
```python
181
181
import plotly.express as px
@@ -233,7 +233,7 @@ fig.show()
233
233
234
234
### Passing dictionaries or array-likes as the data_frame argument
235
235
236
-
The column-based argument `data_frame` can also be passed with a `dict` or `array`. Using a dictionary can be a convenient way to pass column names used in axis titles, legend entries and hovers without creating a DataFrame.
236
+
The column-based argument `data_frame` can also be passed with a `dict` or `array`. Using a dictionary can be a convenient way to pass column names used in axis titles, legend entries and hovers without creating a dataframe.
237
237
238
238
```python
239
239
import plotly.express as px
@@ -261,7 +261,7 @@ fig.show()
261
261
262
262
### Mixing dataframes and other types
263
263
264
-
It is possible to mix DataFrame columns, NumPy arrays and lists as arguments. Remember that the only column names to be used correspond to columns in the `data_frame` argument, use `labels` to override names displayed in axis titles, legend entries or hovers.
264
+
It is possible to mix dataframe columns, NumPy arrays and lists as arguments. Remember that the only column names to be used correspond to columns in the `data_frame` argument, use `labels` to override names displayed in axis titles, legend entries or hovers.
0 commit comments