Python数据分析实战-给定JSON格式的数据提取所需字段并转换为DataFrame(附源码和实现效果)

news/2024/11/17 20:21:31/

实现功能

给定JSON格式的数据提取所需字段并转换为DataFrame

实现代码

import pandas as pd
import json# 假设给定的JSON数据已经存储在data变量中
data = [{"title": "Data Source Adapter for Excel Sheets","project_code_url": "https://github.com/polypheny/Polypheny-DB/pull/418","date_created": "2022-05-17T23:30:01.526934Z","tech_tags": ["java","typescript"],"topic_tags": ["database"],"status": "passed","program_slug": "2022","contributor_display_name": "Kelly Xie","mentor_names": ["Marc Hennemann","Isabel"],"abstract_short": "This project will allow Polypheny to interact with Excel sheets by adding a data source adapter. The Excel adapter enables Polypheny to query the...","abstract_html": "This project will allow Polypheny to interact with Excel sheets by adding a data source adapter. \nThe Excel adapter enables Polypheny to query the mapped data using available query languages of Polypheny-DB and the imported tables can be joined with other tables.","date_archived": "2022-05-17T23:30:01.526934Z","id": "axdeCi5w","organization_name": "Polypheny","organization_slug": "polypheny"},{"title": "Admin Web Portal: New Features Support and Spam Mitigation","project_code_url": "https://docs.google.com/document/d/1KiEZaYkCz7olJ5OeUJKcmuRn1C0qiUJ4UaHvesbcmgc/edit?usp=sharing","date_created": "2022-05-17T23:30:01.954880Z","tech_tags": ["node.js","typescript"],"topic_tags": ["New Features Support","Spam Mitigation"],"status": "passed","program_slug": "2022","contributor_display_name": "Asmit Kumar Sirohi","mentor_names": ["Yasharth Dubey","Jason Gayle"],"abstract_short": "My idea for this GSoC period is basically about improving the UI/UX of the admin portal and making it according to the design standards that are...","abstract_html": "My idea for this GSoC period is basically about improving the UI/UX of the admin portal and making it according to the design standards that are defined in talawa docs, also I will make it mobile responsive. Another focus I have this summer is to make all the screens (components) of talawa-admin functional i.e. No more hard-coded values in the admin portal, all the data will be live from talawa-API. I will also implement a way so that users can select or use talawa-admin in their preferred language and I will be implementing a feature for detecting whether a user is spamming a chat or not. Below are the features for talawa-admin that I am going to add this summer that will boost its usability, user experience, and its use cases.\n\nTalawa-admin Features: \n\nInteractive UI/UX.\nMultiple screens (Mobile or Tablet) are responsive.\nFunctional screens (components).\nImplementing the support for different languages.\nFeature to detect whether the user is spamming the chat or not.\nMigration from redux-routing to react-routing. *","date_archived": "2022-05-17T23:30:01.954880Z","id": "hMUkWQlA","organization_name": "The Palisadoes Foundation","organization_slug": "the-palisadoes-foundation"}
]# 提取所需字段
df_data = []
for d in data:df_data.append({'title': d['title'],'project_code_url': d['project_code_url'],'tech_tags': d['tech_tags'],'topic_tags': d['topic_tags'],'status': d['status'],'contributor_display_name': d['contributor_display_name'],'mentor_names': d['mentor_names'],'id': d['id'],'organization_name': d['organization_name']})# 转换为DataFrame
df = pd.DataFrame(df_data)# 查看结果
print(df)

实现效果

本人读研期间发表5篇SCI数据挖掘相关论文,现在某研究院从事数据挖掘相关科研工作,对数据挖掘有一定认知和理解,会结合自身科研实践经历不定期分享关于python机器学习、深度学习、数据挖掘基础知识与案例。

致力于只做原创,以最简单的方式理解和学习,关注我一起交流成长。

邀请三个朋友关注V订阅号:数据杂坛:即可在后台联系我获取相关数据集和源码,送有关数据分析、数据挖掘、机器学习、深度学习相关的电子书籍。

 


http://www.ppmy.cn/news/1049964.html

相关文章

RandomAccessFile类使用详解

RandomAccessFile类使用详解 1.RandomAccessFile特点 RandomAccessFile是java Io体系中功能最丰富的文件内容访问类。即可以读取文件内容,也可以向文件中写入内容。但是和其他输入/输入流不同的是,程序可以直接跳到文件的任意位置来读写数据。   因为R…

【vue】更改角色权限后,实现页面不刷新更改其可展示的导航菜单

登入的角色本身属于领导级别(集团权限),没有下级的不同权限: 切换不同身份(公司),以获得相应部门的不同导航菜单及权限 这里实现:更改角色权限后,实现页面 不刷新 更改…

第一百二十回 MaterialBanner Widget

文章目录 概念介绍使用方法示例代码 我们在上一章回中介绍了如何通过蓝牙设备读写数据,本章回中将介绍 MaterialBanner Widget.闲话休提,让我们一起Talk Flutter吧。 概念介绍 我们在本章回中将介绍一个新的Widget:MaterialBanner,该Widget位于Scaffol…

基本定时器

1.简介 1. 基本定时器 TIM6 和 TIM7 包含一个 16 位自动重载计数器 2. 可以专门用于驱动数模转换器 (DAC), 用于触发 DAC 的同步电路 3. 16 位自动重载递增计数器 4. 16 位可编程预分频器 5. 计数器溢出时, 会触发中断/DMA请求 从上往下看 1.开始RCC供给定时器的时钟 RCC_APB1…

spring依赖注入详解(上)

一、Bean销毁的过程 如果bean销毁时会执行的场景 1、设置DestroyMethodName为(inferred) // 先把DestroyMethodName设置为(inferred) Component public class TestBeanPostProcessor implements MergedBeanDefinitionPostProcessor {Overridepublic void postProcessMergedBe…

Camtasia导入srt字幕乱码

我们在使用camtasia制作视频项目时,有时为了用户体验需要导入srt格式的字幕文件,在操作无误的情况下,一顿操作猛如虎之后字幕顺利的导入到软件中了,但字幕却出现了乱码的现象。如下图所示: 如何解决srt乱码问题呢&…

Leetcode-每日一题【剑指 Offer 33. 二叉搜索树的后序遍历序列】

题目 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果。如果是则返回 true,否则返回 false。假设输入的数组的任意两个数字都互不相同。 参考以下这颗二叉搜索树: 5 / \ 2 6 / \ 1 3 示例 1: 输入: […

嵌入式基础知识-中断处理过程

本篇来介绍中断,这是计算机系统以及嵌入式系统的重要概念。 1 中断基本概念 中断是CPU对系统发生的某个事件作出的一种反应。 中断的一些基本概念: 中断源:引起中断的事件称为中断源中断请求:中断源向CPU提出处理的请求称为中断…