【发布时间】:2019-07-12 00:27:14
【问题描述】:
我有一个数据框,例如:
Path Attribute
/home/accessbile/wheelchair type:threshold;width:42;gaurded:no
/home/accessible/wheelcahir type:threshold;width:45
/home/accessbile/armchair weight(lbs):100;width:30
/home/accessible/armchair type:foldind;weight(lbs):100;width:30
我需要获取关于路径的值(类型、宽度、重量、gaurded 等)的属性中的唯一计数
输出:
PATH Attributes count
/home/accessbile/wheelchair type 2
/home/accessbile/wheelchair width 2
/home/accessbile/wheelchair gaurded 1
/home/accessbile/armchair weight(lbs) 2
/home/accessbile/armchair width 2
/home/accessbile/armchair type 1
尝试通过ast.eval 将属性转换为dict,并将键作为唯一计数.. 但没有用
【问题讨论】:
标签: python string pandas dictionary