这是json的一个例子。以前,我能够解决不作为嵌套的附件和标签以及作为感应列的问题。任何帮助都是深深的帮助!
factorial
答案 0 :(得分:1)
你可以这样做:
case class students(name: String, age: Int, branch: String, sem: String)
val listStudents = List(students("Rajesh",21,"branch1","sem1"),
students("Kamal",25,"branch2","sem2"),students("Kavitha",23,"branch3","sem3"))
val filteredNames = listStudents.filter(_.branch == "branch2").map(_.name)
注意:第二个参数In [1]: fn = r'D:\temp\.data\40454898.json'
In [2]: with open(fn) as f:
...: data = json.load(f)
...:
In [14]: t = pd.io.json.json_normalize(data['Volumes'],
...: ['Attachments','Tags'],
...: [['Attachments', 'VolumeId'],
...: ['Attachments', 'InstanceId']])
...:
In [15]: t
Out[15]:
Key Value Attachments.InstanceId Attachments.VolumeId
0 Name DBJanitor-Private i-1234567890abcdef0 vol-049df61146c4d7901
1 Owner DBJanitor i-1234567890abcdef0 vol-049df61146c4d7901
2 Product Database i-1234567890abcdef0 vol-049df61146c4d7901
3 Portfolio DB Janitor i-1234567890abcdef0 vol-049df61146c4d7901
4 Service DB Service i-1234567890abcdef0 vol-049df61146c4d7901
是我们的嵌套记录(['Attachments','Tags']
)的路径,第三个参数data['Values']->Attachments->Tags
是外部元数据的路径({ {1}},[['Attachments', 'VolumeId'], ['Attachments', 'InstanceId']]
)