descriptors.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:psst 作者: power-system-simulation-toolbox 项目源码 文件源码
def setattributeindex(self, instance, value):
        bus_name = instance.bus.index
        instance.branch['F_BUS'] = instance.branch['F_BUS'].apply(lambda x: value[bus_name.get_loc(x)])
        instance.branch['T_BUS'] = instance.branch['T_BUS'].apply(lambda x: value[bus_name.get_loc(x)])
        instance.gen['GEN_BUS'] = instance.gen['GEN_BUS'].apply(lambda x: value[bus_name.get_loc(x)])

        try:
            instance.load.columns = [v for b, v in zip(instance.bus_name.isin(instance.load.columns), value) if b == True]
        except ValueError:
            instance.load.columns = value
        except AttributeError:
            instance.load = pd.DataFrame(0, index=range(0, 1), columns=value, dtype='float')

        instance.bus.index = value

        if isinstance(instance.bus_name, pd.RangeIndex) or isinstance(instance.bus_name, pd.Int64Index):
            logger.debug('Forcing string types for all bus names')
            instance.bus_name = ['Bus{}'.format(b) for b in instance.bus_name]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号