VertexFrame unflatten_column¶
-
unflatten_column
(self, composite_key_column_names, delimiter=None)¶ Compacts data from multiple rows based on cell data.
Parameters: composite_key_column_names : list
Name of the column(s) to be used as keys for unflattening.
delimiter : unicode (default=None)
Separator for the data in the result columns. Default is comma (,).
Returns: : _Unit
Groups together cells in all columns (less the composite key) using ”,” as string delimiter. The original rows are deleted. The grouping takes place based on a composite key created from cell values. The column datatypes are changed to string.
Examples
Given a data file:
user1 1/1/2015 1 70 user1 1/1/2015 2 60 user2 1/1/2015 1 65
The commands to bring the data into a frame, where it can be worked on:
>>> my_csv = ta.CsvFile("original_data.csv", schema=[('a', str), ('b', str),('c', int32) ,('d', int32])) >>> my_frame = ta.Frame(source=my_csv)
Looking at it:
>>> my_frame.inspect() a:str b:str c:int32 d:int32 /------------------------------------------------/ user1 1/1/12015 1 70 user1 1/1/12015 2 60 user2 1/1/2015 1 65
Unflatten the data using columns a & b:
>>> my_frame.unflatten_column({'a','b'})
Check again:
>>> my_frame.inspect() a:str b:str c:str d:str /-------------------------------------------/ user1 1/1/12015 1,2 70,60 user2 1/1/2015 1 65