本文整理汇总了Python中etl.ETLUtils.add_transpose_list_column方法的典型用法代码示例。如果您正苦于以下问题:Python ETLUtils.add_transpose_list_column方法的具体用法?Python ETLUtils.add_transpose_list_column怎么用?Python ETLUtils.add_transpose_list_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类etl.ETLUtils
的用法示例。
在下文中一共展示了ETLUtils.add_transpose_list_column方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_categories
# 需要导入模块: from etl import ETLUtils [as 别名]
# 或者: from etl.ETLUtils import add_transpose_list_column [as 别名]
def get_categories(file_path):
records = ETLUtils.load_json_file(file_path)
# Now we obtain the categories for all the businesses
records = ETLUtils.add_transpose_list_column('categories', records)
BusinessETL.drop_unwanted_fields(records)
return records[0].keys()
示例2: create_category_matrix
# 需要导入模块: from etl import ETLUtils [as 别名]
# 或者: from etl.ETLUtils import add_transpose_list_column [as 别名]
def create_category_matrix(file_path):
"""
Creates a matrix with all the categories for businesses that are
contained in the Yelp Phoenix Business data set. Each column of the
matrix represents a category, and each row a business. This is a binary
matrix that contains a 1 at the position i,j if the business i contains
the category j, and a 0 otherwise.
:rtype : numpy array matrix
:param file_path: the path for the file that contains the businesses
data
:return: a numpy array binary matrix
"""
records = ETLUtils.load_json_file(file_path)
# Now we obtain the categories for all the businesses
records = ETLUtils.add_transpose_list_column('categories', records)
BusinessETL.drop_unwanted_fields(records)
matrix = numpy.array(
[numpy.array(record.values()) for record in records])
return matrix