def data_as_triangle(self, inplace=False):
"""Method to convert tabular form to triangle form.
Arguments:
inplace: bool
Set to True will update the instance data attribute inplace
Returns:
Updated instance `data` parameter if inplace is set to True otherwise it returns a pandas.DataFrame
"""
if self.dataform == 'tabular':
tri = pivot_table(self.data, values=self.values, index=[
self.origin], columns=[self.dev]).sort_index()
tri.columns = [str(item) for item in tri.columns]
if inplace == True:
self.data = tri
self.dataform = 'triangle'
return tri
else:
return self.data
评论列表
文章目录