相关疑难解决方法(0)

一个文件中的多个Json对象由python提取

我是Json文件的新手.如果我有一个带有多个json对象的json文件,如下所示:

{"ID":"12345","Timestamp":"20140101", "Usefulness":"Yes",
  "Code":[{"event1":"A","result":"1"},…]}
{"ID":"1A35B","Timestamp":"20140102", "Usefulness":"No",
  "Code":[{"event1":"B","result":"1"},…]}
{"ID":"AA356","Timestamp":"20140103", "Usefulness":"No",
  "Code":[{"event1":"B","result":"0"},…]}
…
Run Code Online (Sandbox Code Playgroud)

我想将所有"时间戳"和"有用性"提取到数据框中:

    Timestamp    Usefulness
 0   20140101      Yes
 1   20140102      No
 2   20140103      No
 …
Run Code Online (Sandbox Code Playgroud)

有谁知道处理这些问题的一般方法?谢谢!

python parsing json pandas

31
推荐指数
4
解决办法
7万
查看次数

与熊猫的高性能笛卡儿产品(CROSS JOIN)

这篇文章的内容最初是作为Pandas Merging 101的一部分,但由于完全公开 这个主题所需的内容的性质和大小,它已被转移到自己的QnA.

给出两个简单的DataFrame;

left = pd.DataFrame({'col1' : ['A', 'B', 'C'], 'col2' : [1, 2, 3]})
right = pd.DataFrame({'col1' : ['X', 'Y', 'Z'], 'col2' : [20, 30, 50]})

left

  col1  col2
0    A     1
1    B     2
2    C     3

right

  col1  col2
0    X    20
1    Y    30
2    Z    50
Run Code Online (Sandbox Code Playgroud)

可以计算这些帧的叉积,看起来像:

A       1      X      20
A       1      Y      30
A       1      Z      50
B       2      X      20
B       2      Y      30
B       2      Z      50 …
Run Code Online (Sandbox Code Playgroud)

python merge numpy dataframe pandas

31
推荐指数
3
解决办法
6191
查看次数

标签 统计

pandas ×2

python ×2

dataframe ×1

json ×1

merge ×1

numpy ×1

parsing ×1