three right left right pivoting "longto "wideformat common way to store multiple time series in databases and csv is in so-called long or stacked formatin [ ]ldata[: out[ ]date : : : : : : : : : : : : : : : : : : : : item realgdp infl unemp realgdp infl unemp realgdp infl unemp realgdp value data is frequently stored this way in relational databases like mysql as fixed schema (column names and data typesallows the number of distinct values in the item column to increase or decrease as data is added or deleted in the table in the above example date and item would usually be the primary keys (in relational database parlance)offering both relational integrity and easier joins and programmatic queries in many cases the downsideof courseis that the data may not be easy to work with in long formatyou might prefer to have dataframe containing one column per distinct item value indexed by timestamps in the date column dataframe' pivot method performs exactly this transformationin [ ]pivoted ldata pivot('date''item''value'in [ ]pivoted head(out[ ]item infl realgdp unemp date the first two values passed are the columns to be used as the row and column indexand finally an optional value column to fill the dataframe suppose you had two value columns that you wanted to reshape simultaneouslyin [ ]ldata['value 'np random randn(len(ldata)in [ ]ldata[: out[ ] data wranglingcleantransformmergereshape www it-ebooks info