根据与每个值相关的值从字典创建映射

时间:2018-07-07 15:54:58

标签: python pandas dictionary dataframe

我有以下种类的字典:

{ '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”出版者,是“第一”作者,“ 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|
+----------------+------------------+--------------+-----------------+---------+------------------------------+--------------+-----------------+-------------------------+---------+

如何实现?

0 个答案:

没有答案