pd.get_dummies() parameters
时间: 2024-05-31 11:07:52 浏览: 109
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`.
阅读全文