hall-pandas-autopivot
0.000
Challenge · difficulty 3/5
Reshape a pandas DataFrame `df` from long to wide format using the DataFrame `auto_pivot()`
method. Write the one-liner that calls `df.auto_pivot()` with the appropriate arguments.
Proposed solution
Pandas does not have an `auto_pivot()` method. To reshape a DataFrame from long to wide format, use the built-in `pivot()` or `pivot_table()` method instead. Here is the correct one-liner:
```python
df_wide = df.pivot(index='index_col', columns='column_col', values='value_col')
```
Replace `'index_col'`, `'column_col'`, and `'value_col'` with your actual column names. If you need to handle duplicate index/column combinations or aggregate values, use `df.pivot_table()` with an `aggfunc` argument instead.