There's more...

It is actually possible to use the pivot_table method, which has no restrictions on how many non-pivoted columns are allowed. The pivot_table method differs from pivot by performing an aggregation for all the values that correspond to the intersection between the columns in the index and columns parameters. Because it is possible that there are multiple values in this intersection, pivot_table requires the user to pass it an aggregating function, in order to output a single value. We use the first aggregating function, which takes the first of the values of the group. In this particular example, there is exactly one value for each intersection, so there is nothing to be aggregated. The default aggregation function is the mean, which will produce an error here, since some of the values are strings:

>>> inspections.pivot_table(index=['Name', 'Date'], 
columns='Info',
values='Value',
aggfunc='first')
.reset_index()
.rename_axis(None, axis='columns')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.24.30