当前位置: 首页>>代码示例>>Python>>正文


Python DictReader.__next__方法代码示例

本文整理汇总了Python中csv.DictReader.__next__方法的典型用法代码示例。如果您正苦于以下问题:Python DictReader.__next__方法的具体用法?Python DictReader.__next__怎么用?Python DictReader.__next__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在csv.DictReader的用法示例。


在下文中一共展示了DictReader.__next__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: locations

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __next__ [as 别名]
def locations(rack_locations_path=RACKS_LOCATION_CSV):
    with open(rack_locations_path, 'r') as file:
        csv_file = DictReader(file,
                              ["latitude", "longitude", "icon", "desc", "racks_count", "parking_places"])
        acc = []
        csv_file.__next__()  # Skip the header
        for attributes in csv_file:
            acc.append(RacksLocation(attributes))

        return acc
开发者ID:maciej,项目名称:waw-bike-racks,代码行数:12,代码来源:rack_locations.py

示例2: __next__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __next__ [as 别名]
 def __next__(self): # For Python 3
     row = DictReader.__next__(self)
     for (att, func) in self._casts.items():
         row[att] = func(row[att])
     return row
开发者ID:harryprince,项目名称:pygrametl,代码行数:7,代码来源:datasources.py

示例3: DictReader

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __next__ [as 别名]

threshold = 0.5

label_path = path + 'validation.csv'
predict_path = path + 'submission.csv'

label_reader = DictReader(open(label_path))
predict_reader = DictReader(open(predict_path))

count = 0
y_true = []
y_pred = []
y_scores = []
for t, row in enumerate(label_reader):
    predict = predict_reader.__next__()
    actual = float(row['label'])
    predicted = float(predict['prob'])
    y_true.append(actual)
    y_scores.append(predicted)

    # 大于阈值的即视为点击
    if predicted >= threshold:
        y_pred.append(1)
    else:
        y_pred.append(0)
    count += 1

# 计算性能指标
auc = roc_auc_score(y_true, y_scores)
logloss = log_loss(y_true, y_scores)
开发者ID:zgcgreat,项目名称:WSDM,代码行数:32,代码来源:evaluate.py


注:本文中的csv.DictReader.__next__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。