从复杂的字符串中提取信息

时间:2019-06-20 18:33:58

标签: python string

嗨,我在Panda Arrary中有以下两列。如您所见,第二列中的信息包含很多信息。据我了解,它是某种形式的“列表”,但带有双引号而不是单引号。

 Customer Name  Details
Jacob   "[{""Name"":""Phone"",""Value"":""03477444556""},{""Name"":""Type"",""Value"":""Apartment""},{""Name"":""No - Name"",""Value"":""1210""},{""Name"":""Apartment N    me"",""Value"":""Khudadaad Height  E-11\/1""},{""Name"":""Street"",""Value"":null},{""Name"":""Sector"",""Value"":null},{""Name"":""Landmark"",""Value"":null}]"
John    "[{""Name"":""Phone"",""Value"":""03477444550""},{""Name"":""Type"",""Value"":null},{""Name"":""No - Name"",""Value"":""10""},{""Name"":""Apartment Name"",""Val    e"":""Khudadaad Height  E-11\/1""},{""Name"":""Street"",""Value"":null},{""Name"":""Sector"",""Value"":null},{""Name"":""Landmark"",""Value"":null}]"
Smith   "[{""Name"":""Phone"",""Value"":""03475649292""},{""Name"":""Type"",""Value"":""House""},{""Name"":""No - Name"",""Value"":""1 a""},{""Name"":""Apartment Name""    ""Value"":null},{""Name"":""Street"",""Value"":null},{""Name"":""Sector"",""Value"":""f 7 3""},{""Name"":""Landmark"",""Value"":null}]"
Adam    "[{""Name"":""Phone"",""Value"":""03466700079""},{""Name"":""Type"",""Value"":""Office""},{""Name"":""No - Name"",""Value"":""ptcl head quarter""},{""Name"":""A    artment Name"",""Value"":null},{""Name"":""Street"",""Value"":null},{""Name"":""Sector"",""Value"":""g\/8\/4""},{""Name"":""Landmark"",""Value"":null}]"
Carlos  "[{""Name"":""Phone"",""Value"":""03466700079""},{""Name"":""Type"",""Value"":""Office""},{""Name"":""No - Name"",""Value"":""ptcl head quarter""},{""Name"":""A    artment Name"",""Value"":null},{""Name"":""Street"",""Value"":null},{""Name"":""Sector"",""Value"":""g\/8\/4""},{""Name"":""Landmark"",""Value"":null}]"
Ali     "[{""Name"":""Phone"",""Value"":""03465403134""},{""Name"":""Type"",""Value"":""House""},{""Name"":""No - Name"",""Value"":""55-B ""},{""Name"":""Apartment Name    ",""Value"":null},{""Name"":""Street"",""Value"":""21""},{""Name"":""Sector"",""Value"":""F 10\/2""},{""Name"":""Landmark"",""Value"":null}]"

无论如何,这就是我解释此信息的方式。针对每个客户,它包含七个不同的行,每个行中包含四个不同的值。因此,对于第一个客户Jacob,第1行和第4列的值为“ 03477444556”。每个客户的这一行包含他们的电话号码。同样,针对每个客户的第3行,第4列包含其位置。

我有兴趣创建一列,其中包含所有客户的电话号码。我该如何做,以便从上面我可以得到这个:

Customer Name | Phone Number 
  Jacob         |  03477444556 
  John          | 034777444550 
  Smith         |  03475649292 
  Adam          |  03466700079 
  Carlos        |  03466700079 
  Ali           |  03465403132 

并且能够对master列中包含的所有信息执行以上操作。

0 个答案:

没有答案