python - 根据每个值的关联值从字典创建映射
问题描述
我有以下类型的字典:
{ 'Publisher_name': [( 'Sun Publications', '0')], 'Author_Book Ratio': [(1.27364726, '00')
, (0.765346483, '01')], 'Book_series_no': [(1, '000'), (2, '001'),
(1, '010'), (2, '011')], 'Volume_No': [(1, '0010'), (2, '0011')],
'publishing_status': [( 'Y', '000'), ( 'Y', '001'), ( 'N', '010'), ( 'Y', '011')],
'Volume_name': [( 'Perils of Annoyance Vol.1', '0010'), ( 'Perils of Annoyance Vol.2', '0011')],
'Book_name': [( 'Thoughts of a River Bound Duck', '000'),
( 'Perils of Annoyance', '001'), ( 'Welcome to the Valley', '010'),
( 'Open the box', '011')], 'Author_name': [( 'August Oliver', '00'),
( 'Pierce Rhombus', '01')], 'Author_ID': [(3, '00'), (2, '01')],
'timestamp': [( '01-Aug-17 13:25:32', '0')]}
每个值附带的数字描述了元素所属的级别和父级。带有“00”的作者详细信息表示它属于第“0”个出版商,是“1”的作者,“001”表示该书属于第0个出版商,第0个作者,是他的第0本书。所有的值都是相似的。如果特定父节点或子节点没有值,则该列将填充为空。我想从这个字典中创建一个数据框,它将是以下排序-
+----------------+------------------+--------------+-----------------+---------+------------------------------+--------------+-----------------+-------------------------+---------+
| Publisher_name| timestamp| Author_name|Author_Book_Ratio|Author_ID| Book_name|Book_series_no|publishing_status| Volume_name|Volume_No|
+----------------+------------------+--------------+-----------------+---------+------------------------------+--------------+-----------------+-------------------------+---------+
|Sun Publications|01-Aug-17 13:25:32| August Oliver| 1.27364726| 3|Thoughts of a River Bound Duck| 1| Y| Null| Null|
|Sun Publications|01-Aug-17 13:25:32| August Oliver| 1.27364726| 3| Perils of Annoyance| 2| Y|Perils of Annoyance Vol.1| 1|
|Sun Publications|01-Aug-17 13:25:32| August Oliver| 1.27364726| 3| Perils of Annoyance| 2| Y|Perils of Annoyance Vol.2| 2|
|Sun Publications|01-Aug-17 13:25:32|Pierce Rhombus| 0.765346483| 2| Welcome to the Valley| 1| N| Null| Null|
|Sun Publications|01-Aug-17 13:25:32|Pierce Rhombus| 0.765346483| 2| Open the box| 2| Y| Null| Null|
+----------------+------------------+--------------+-----------------+---------+------------------------------+--------------+-----------------+-------------------------+---------+
如何做到这一点?
解决方案
推荐阅读
- git - 通过更新父分支从子分支 PR 中删除更改
- appium - 带有 Android 模拟器的 SauceLabs 隧道无法正常工作
- java - 将此格式 20210526T150239 的时间转换为此格式 2021-05-26T12:56:21.826
- javascript - 对消息中缺少 ID 的表情符号做出反应
- apache-kafka - 来自 kafka AdminClient 的警告消息
- css - 如何删除 Firefox 89+(Proton)中复选框/单选按钮周围的焦点可见样式?
- python - 如何使用 for 循环和导入的 string.punctuation 作为列表删除标点符号?
- python - 刮痧套装店铺位置
- nvidia - Archlinux笔记本电脑屏幕更新后停止工作
- c# - 添加迁移时出现构建错误