pd.get_dummies() parameters
时间: 2024-05-31 11:07:52 浏览: 12
The `pd.get_dummies()` function in pandas has the following parameters:
- `data`: This is the input data, which can be a pandas DataFrame, Series, or any array-like object.
- `prefix`: This parameter specifies the string to prepend to the column names of the resulting dummy variables. By default, the prefix is the original column name.
- `prefix_sep`: This parameter specifies the string to separate the prefix from the original column name. By default, it is an underscore `_`.
- `columns`: This parameter specifies the columns to encode as dummy variables. If not specified, all columns with object or categorical data types will be encoded.
- `dtype`: This parameter specifies the data type of the resulting dummy variables. By default, it is inferred from the input data.
- `drop_first`: This parameter specifies whether to drop the first level of each categorical variable when encoding. By default, it is `False`.
- `dummy_na`: This parameter specifies whether to create a dummy variable for missing values. By default, it is `False`.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![none](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)