The collected data is usually divided into multiple files or databases after storage. How to splice these files as needed or connect them by key is very important. This section will introduce the complex operations of data indexing such as hierarchical index, stack, unstack, seet_index, reset_index, etc. to help reconstruct data, data splicing such as merge, join, concat, combine_first, etc. to help connect data, as well as the use of pivot tables.
Table of contents
pivot table
C.1 df.pivot
Assume that the current data is deconstructed as shown in the table below. The item column represents different keys (can be converted into many columns), and the value represents different values.
Now we want to convert it into a regular Df New style, that is, each column is a kind of data using Df.pivot(index=, columns='item',value=)
as shown below:
- The effect achieved is similar to moving the item column to the column index.