首页 文章 精选 留言 我的

精选列表

搜索[工具模块],共10000篇文章
优秀的个人博客,低调大师

核心基于字节跳动联名论文,可将视频、图片一键卡通化的开源工具

前段时间,有人根据一篇字节跳动联名的AI 论文,做了个可将视频、图片一键卡通化的Web端应用Cartoonize。 Cartoonize Cartoonize 现在已经开源,使用非常简单,只要上传需要转换的图片、视频即可。Cartoonize 转换可以很好地还原原图细节,下面是人像、风景、食物等实景的转化图。 Cartoonize 还支持10秒以内的视频转换,上一段《复仇者联盟》视频转化效果。 (官网转换视频截图,实际视频效果可进官网查看) 据其官网介绍,Cartoonize 适合四种场景的转换:快速制作动画,卡通和游戏的原型;由于它通常可柔化面部特征和信息,因此可用于生成最小单位的艺术做品;无需使用动作捕捉,游戏可以很容易地导入短视频;可以为图形设计师或动画师做建模助手。 对可转换图片视频的大小格式,Cartoonize 做了一定限制,目前只支持转换10秒及以内的视频,视频文件最大为30 MB,支持的格式包括 mp4、webm、avi、mkv。支持的图像文件格式为 jpeg、png,不支持 GIG/TIFF 图像。 算法: Cartoonize 使用Algorithmia 的 Serveless AI Layer 产品对视频进行推理。 测试环境: python 3.7 tensorflow2.1.0 tf_slim 1.1.0 Cudaversion10.1 操作系统:Linux(Ubuntu 18.04) 安装: 使用 Docker: 运行 Cartoonize 最简单方法是使用 Dockerfile: cd到根目录并构建映像 docker build -t cartoonize . 注意:config.yaml在构建图像之前,请设置适当的值。 2. 通过暴露适当的端口来运行容器 docker run -p 8080:8080 cartoonize 使用 virtualenv 使用virtualenv并激活虚拟环境 virtualenv -p python3 cartoonize source cartoonize/bin/activate 2. 安装 python 依赖项 pip install -r requirements.txt 3. 运行网络应用。config.yaml在运行应用程序之前,请确保在文件中设置适当的值。 python app.py 项目官网:https://cartoonize-lkqov62dia-de.a.run.app/cartoonize White-box-Cartoonization:白盒图像卡通化模型 如果想了解更多影像资料卡通化的训练模型和过程,可以查看 Cartoonize 背后的技术论文和项目。事实上,Cartoonize 是 White-box-Cartoonization的一个 Demo webapp。Cartoonize核心技术来自 CVPR 2020的投稿论文《Learning to Cartoonize Using White-box Cartoon Representations》,该论文作者系字节跳动、东京大学、Style2Paints Research 人员。 该论文提出了一种基于 GAN 的白盒可控的图像卡通化模型。 论文指出,各种卡通风格和用处需要基于特定任务或者先验知识才能开发可用的算法。例如有些卡通画更关注全局色调,线条清晰度在次;有些强调稀疏和干净的色块,对主题强调少。然而这些变量因素给黑盒模型带来了不小的挑战,如当面对艺术家不同的需求时,简单地更改训练数据集就于事无补了。使用黑盒模型直接拟合训练数据会降低其通用性和风格化质量,在一些情况下导致较差效果。 通常来说,黑盒模型通常有很高的准确性,但是其内部工作难以理解和改动,并且它们不能估计每个特征对模型预测的重要性,也不容易理解不同特征之间如何相互作用。而白盒模型则可以更为自由地修改模型中的某些算法,使之更加灵活地适应不同需求场景。 论文作者指出,为了解决黑盒模型的一些问题,他们对人们的绘画行为和不同风格的卡通形象进行了大量的观察,并咨询了几位卡通艺术家,建议将图像分解为几种卡通表征方式:提取一个带权重的低频内容,表示图片的轮廓表征;针对输入图像,提取分割图,在每个分割区域使用一个自适应的色彩算法生成结构表征;保持绘画细节和边缘的纹理表征。 The separately extracted cartoon representations enable the cartooniaztion problem to be optimized end-to-end within a Generative Neural Networks (GAN) framework,making it scalable and controllable for practical use casesand easy to meet diversified artistic demands with taskspecific fine-tuning. 单独提取的卡通表征形式使卡通化问题可以在生成神经网络(GAN)框架内进行端到端的优化,在实际使用场景中,使其可扩展和可控,易于满足不同的技术需求,也可以根据需求进行微调。 基于该论文的 White-box-Cartoonization 现在已经部分开源。 安装使用: 先决条件: 培训代码:Linux 或 Windows NVIDIA GPU + CUDA CuDNN 性能 推断代码:Linux,Windows 和 MacOS 安装: 假设已经安装了 NVIDIA GPU 和 CUDA CuDNN 安装 tensorflow-gpu,已经测试过 1.12.0 和 1.13.0rc0 安装 scikit-image == 0.14.5,其他版本可能会带来问题 预训练模型推论: 将测试图像存储在/test_code/test_images 中 运行/test_code/cartoonize.py 结果将保存在/test_code/cartoonized_images 中 训练: 将训练数据放在/dataset 中的相应文件夹中 运行 pretrain.py,结果将保存在/pretrain 文件夹中 运行 train.py,结果将保存在/train_cartoon 文件夹中 从生产环境中清除代码,并且未经测试 可能会有一些小问题,但应该很容易解决 可以在以下网址找到预训练的 VGG_19模型:https://drive.google.com/file/d/1j0jDENjdwxCDb36meP6-u5xDBzmKBOjJ/view 数据集: 由于版权问题,无法提供用于训练的卡通图像,但是这些训练数据集很容易准备 风景图来自新海诚,宫崎骏和细田守拍摄的电影 将影片剪辑成帧,并随机裁剪调整为256x256 人像图像来自京都动画和 PA Works 使用此仓库(https://github.com/nagadomi/lbpcascade_animeface)检测面部区域 手动清理数据将大大提高两个数据集的质量

优秀的个人博客,低调大师

macOS 终端工具 iTerm2 被发现一个存在 7 年的重大漏洞

此漏洞会允许攻击者在用户电脑上远程执行命令,Mozilla 提醒用户应该立即主动升级软件。 iTerm2 是非常流行的终端模拟器,被许多开发者与系统管理员广泛使用,不少人甚至会用它来处理一些不受信任的数据,因此 MOSS(Mozilla Open Source Support Program) 这次选了 iTerm2,并委托 ROS(Radially Open Security)进行安全审核工作。 据了解,这个漏洞在 iTerm2 中已存在长达 7 年,目前分配到的编号为CVE-2019-9535。这个漏洞可以让攻击者在使用者电脑上执行命令。 说起漏洞,iTerm2 这个重大的安全漏洞由 MOSS 资助的安全审核团队发现,MOSS 于 2015 年成立,从那时起就开始为开源开发者提供资金支持、协助开源与自由软件的发展。同时还支持开源技术的安全审核,MOSS 的资金正是来自 Mozilla 基金会,以确保开源生态健康发展。 ROS 发现 iTerm2 中的 tmux 整合功能有严重的漏洞,而且漏洞至少已经存在 7 年。简单来说,在大多数情况下,允许攻击者可对终端产生输出,也就是能在用户的电脑上执行命令。ROS 提供了攻击的 demo,而视频内容主要是进行表达概念性验证,因此当用户连接到恶意的 SSH 服务器后,攻击者仅示范开启的计算机程序,实际上还可以进行更多恶意指令。 Mozilla 则提到,这个漏洞需要与用户进行一定程度的互动,然后攻击者才能进行后续的攻击行动,但是由于使用普遍认为安全的指令就会受到攻击,因此被认为有高度的潜在安全影响。现在 Mozilla、ROS 与 iTerm2 开发者密切合作,推出了最新 3.3.6 版本,而 3.3.5 的安全修补程式也已经发布。Mozilla 表示,虽然软件会主动提示更新,但是希望开发者能主动进 行更新,减少可能被攻击机会。 目前 iTerm2 开发者现在已经发布最新的 3.3.6 版本,Mozilla 也提醒使用者应该要尽快更新。

优秀的个人博客,低调大师

Twitter 开源高分辨率遥测工具 Rezolus,轻松捕获系统性能异常瞬间

Twitter 昨日宣布开源Rezolus,这是一种高分辨率遥测代理,旨在发现性能异常现象和利用率峰值,这些异常现象和峰值通常都太短暂,难以通过常规观察和系统指标来捕获。Rezolus有助于量化工作负载,提供数据以推进优化,并且已经用于诊断运行时的性能问题。Twitter 已经在 Rezolus 上运行了一年多。 “Rezolus 提供了一系列信号,以帮助我们理解细粒度的运行时行为。我们发现它对理解和优化性能特别有帮助”,Twitter 工程师 Brian Martin 在博客文章中写道,“通过单一代理,我们可以从各种来源获得遥测。据我们所知,没有其他开源项目能够在单个软件包中展现如此全面的洞察力。” 根据Martin 的说法,Rezolus 诞生于对了解细粒度时间尺度上的系统性能的需求。在运行非常高吞吐量的综合基准测试时,Twitter 工程师们有时会遇到短暂的性能异常,但现有的遥测技术采样率相对较低,因此未能反映出这些异常状况。 这是因为,根据采样定理,采样率必须至少是最短脉冲持续时间的两倍,以便准确地反映爆发的强度,而大多数遥测都会产生一个微小的时间序列。相比之下,Rezolus 可以在更加精确的时间尺度上精确测量性能下降的情况。 Rezolus 允许配置采样率,因此开发人员可以将分辨率与尖峰长度匹配,并且不会消耗过多的资源。在 10Hz 采样时,它能够反映出 200 毫秒或更长时间的连续突发,足以满足 Twitter 上的大多数服务。同时,在这一条件下它只占用不超过 15% CPU 和 60MB 内存。 可切换的插件采样器使 Rezolus 能够从各种来源收集遥测,包括来自 Linux kernel 源的计数器和仪表,以获得有关 CPU 使用率、网络利用率和磁盘利用率的遥测。这些采样器还可根据需要进行不同配置。 最后,Martin 写道:“开源 Rezolus 标志着该项目的一个重要里程碑,我们希望 Rezolus 对 Twitter 之外的其他人也有用,并期待围绕它建立一个社区。” 博客原文:https://blog.twitter.com/engineering/en_us/topics/open-source/2019/introducing-rezolus.html

优秀的个人博客,低调大师

python人工智能机器学习工具书籍: scikit-learn Cookbook 2nd Edition

简介 本书包括对机器学习中常见问题和不常见问题的演练和解决方案,以及如何利用scikit-learn有效地执行各种机器学习任务。 第二版首先介绍评估数据统计属性的方法,并为机器学习建模生成合成数据。当您逐步完成这些章节时,您会遇到一些食谱,它们将教您实施数据预处理,线性回归,逻辑回归,KNN,NaïveBayes,分类,决策树,合奏等技术。 此外,您将学习使用多级分类,交叉验证,模型评估来优化您的模型,并深入学习使用scikit-learn实现深度学习。 除了涵盖模型部分,API和分类器,回归器和估算器等新功能的增强功能外,本书还包含评估和微调模型性能的方法。在本书的最后,您将探索用于Python的scikit-learn提供的众多功能,以解决您遇到的任何机器学习问题。 参考资料 下载:https://www.jianshu.com/p/c2

优秀的个人博客,低调大师

[雪峰磁针石博客]2018最佳人工智能数据采集(爬虫)工具书下载

Python网络数据采集 Python网络数据采集 - 2016.pdf 本书采用简洁强大的Python语言,介绍了网络数据采集,并为采集新式网络中的各种数据类型提供了全面的指导。第 1部分重点介绍网络数据采集的基本原理:如何用Python从网络服务器请求信息,如何对服务器的响应进行基本处理,以及如何以自动化手段与网站进行交互。第 二部分介绍如何用网络爬虫测试网站,自动化处理,以及如何通过更多的方式接入网络。 Web Scraping with Python 2nd - 2018.pdf https://github.com/REMitchell/python-scraping 2000左右星 精通Python爬虫框架Scrapy Scrapy是使用Python开发的一个快速、高层次的屏幕抓取和Web抓取框架,用于抓Web站点并从页面中提取结构化的数据。《精通Python爬虫框架Scrapy》以Scrapy 1.0版本为基础,讲解了Scrapy的基础知识,以及如何使用Python和三方API提取、整理数据,以满足自己的需求。 本书共11章,其内容涵盖了Scrapy基础知识,理解HTML和XPath,安装Scrapy并爬取一个网站,使用爬虫填充数据库并输出到移动应用中,爬虫的强大功能,将爬虫部署到Scrapinghub云服务器,Scrapy的配置与管理,Scrapy编程,管道秘诀,理解Scrapy性能,使用Scrapyd与实时分析进行分布式爬取。本书附录还提供了各种软件的安装与故障排除等内容。本书适合软件开发人员、数据科学家,以及对自然语言处理和机器学习感兴趣的人阅读。 源码 github星级 300左右 Learning Scrapy -2016.pdf 另有中文电子版本 因为版权已经在CSDN等网站下架,可以在qq群144081101等找到。 python3爬虫基础 在线教程 https://github.com/MorvanZhou/easy-scraping-tutorial 200 左右星 First web scraper 教程:https://first-web-scraper.readthedocs.io/en/latest/ https://github.com/ireapps/first-web-scraper/blob/master/docs/index.rst 200 左右星 Practical Web Scraping for Data Science -Best Practices and Examples with Python - 2018.pdf https://github.com/Apress/practical-web-scraping-for-data-science 星级 低于100 This book provides a complete and modern guide to web scraping, using Python as the programming language, without glossing over important details or best practices. Written with a data science audience in mind, the book explores both scraping and the larger context of web technologies in which it operates, to ensure full understanding. The authors recommend web scraping as a powerful tool for any data scientist’s arsenal, as many data science projects start by obtaining an appropriate data set. Starting with a brief overview on scraping and real-life use cases, the authors explore the core concepts of HTTP, HTML, and CSS to provide a solid foundation. Along with a quick Python primer, they cover Selenium for JavaScript-heavy sites, and web crawling in detail. The book finishes with a recap of best practices and a collection of examples that bring together everything you've learned and illustrate various data science use cases. 用Python写网络爬虫 第2版 《用Python写网络爬虫(第 2版》讲解了如何使用Python来编写网络爬虫程序,内容包括网络爬虫简介,从页面中抓取数据的3种方法,提取缓存中的数据,使用多个线程和进程进行并发抓取,抓取动态页面中的内容,与表单进行交互,处理页面中的验证码问题,以及使用Scarpy和Portia进行数据抓取,并在最后介绍了使用本书讲解的数据抓取技术对几个真实的网站进行抓取的实例,旨在帮助读者活学活用书中介绍的技术。 《用Python写网络爬虫(第 2版》适合有一定Python编程经验而且对爬虫技术感兴趣的读者阅读。 Python Web Scraping 2nd Edition - 2017.pdf 第一版中文 用Python写网络爬虫.pdf https://github.com/kjam/wswp < 100星 Python Web Scraping Cookbook - 2018.pdf 下载 Python Web Scraping Cookbook is a solution-focused book that will teach you techniques to develop high-performance Scrapers, and deal with cookies, hidden form fields, Ajax-based sites and proxies. You'll explore a number of real-world scenarios where every part of the development or product life cycle will be fully covered. You will not only develop the skills to design reliable, high-performing data flows, but also deploy your codebase to Amazon Web Services (AWS). If you are involved in software engineering, product development, or data mining or in building data-driven products, you will find this book useful as each recipe has a clear purpose and objective. Right from extracting data from websites to writing a sophisticated web crawler, the book's independent recipes will be extremely helpful while on the job. This book covers Python libraries, requests, and BeautifulSoup. You will learn about crawling, web spidering, working with AJAX websites, and paginated items. You will also understand to tackle problems such as 403 errors, working with proxy, scraping images, and LXML. By the end of this book, you will be able to scrape websites more efficiently and deploy and operate your scraper in the cloud. https://github.com/PacktPublishing/Python-Web-Scraping-Cookbook < 100星 参考资料 https://github.com/lorien/awesome-web-scraping/blob/master/python.md 最好用的Python爬虫推荐 https://www.jianshu.com/p/7da43c16dd87 https://www.zhihu.com/question/41277528

优秀的个人博客,低调大师

[雪峰磁针石博客]数据分析工具pandas快速入门教程4-数据汇聚

我们需要的所有信息可能记录在单独的文件和数据帧中。例如,可能有一个公司信息单独表和股票价格表,数据被分成独立的表格以减少冗余信息。 连接 添加行 4-1.py import pandas as pd df1 = pd.read_csv('data/concat_1.csv') df2 = pd.read_csv('data/concat_2.csv') df3 = pd.read_csv('data/concat_3.csv') print(df1) print(df2) print(df3) row_concat = pd.concat([df1, df2, df3]) print(row_concat) print(row_concat.iloc[3, ]) new_row_series = pd.Series(['n1', 'n2', 'n3', 'n4']) print(pd.concat([df1, new_row_series])) new_row_df = pd.DataFrame([['n1', 'n2', 'n3', 'n4']], columns=['A', 'B', 'C', 'D']) print(new_row_df) print(pd.concat([df1, new_row_df])) print(df1.append(df2)) print(df1.append(new_row_df)) data_dict = {'A': 'n1', 'B': 'n2', 'C': 'n3', 'D': 'n4'} print(df1.append(data_dict, ignore_index=True)) row_concat_i = pd.concat([df1, df2, df3], ignore_index=True) print(row_concat_i) 执行结果 $ python3 4-1.py A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 A B C D 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 A B C D 0 a8 b8 c8 d8 1 a9 b9 c9 d9 2 a10 b10 c10 d10 3 a11 b11 c11 d11 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 0 a8 b8 c8 d8 1 a9 b9 c9 d9 2 a10 b10 c10 d10 3 a11 b11 c11 d11 A a3 B b3 C c3 D d3 Name: 3, dtype: object A B C D 0 0 a0 b0 c0 d0 NaN 1 a1 b1 c1 d1 NaN 2 a2 b2 c2 d2 NaN 3 a3 b3 c3 d3 NaN 0 NaN NaN NaN NaN n1 1 NaN NaN NaN NaN n2 2 NaN NaN NaN NaN n3 3 NaN NaN NaN NaN n4 A B C D 0 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 4 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 4 a4 b4 c4 d4 5 a5 b5 c5 d5 6 a6 b6 c6 d6 7 a7 b7 c7 d7 8 a8 b8 c8 d8 9 a9 b9 c9 d9 10 a10 b10 c10 d10 11 a11 b11 c11 d11 添加列 4-2.py In [1]: from numpy import NaN, NAN, nan In [2]: print(NaN == True, NaN == False, NaN == 0, NaN == '', sep='|') False|False|False|False In [3]: print(NaN == NaN, NaN == nan, NaN == NAN, nan == NAN, sep='|') False|False|False|False In [4]: import pandas as pd In [5]: print(pd.isnull(NaN), pd.isnull(nan), pd.isnull(NAN), sep='|') True|True|True In [6]: print(pd.notnull(NaN), pd.notnull(99), pd.notnull("https://china-testing.github.io"), sep='|') False|True|True 执行结果 $ python3 4-2.py A B C D A B C D A B C D 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 A A A 0 a0 a4 a8 1 a1 a5 a9 2 a2 a6 a10 3 a3 a7 a11 A B C D A B C D A B C D new_col_list 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 n1 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 n2 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 n3 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 n4 A B C D A B C D A B C D new_col_list \ 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 n1 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 n2 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 n3 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 n4 new_col_series 0 n1 1 n2 2 n3 3 n4 0 1 2 3 4 5 6 7 8 9 10 11 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 合并不同区间 4-3.py import pandas as pd df1 = pd.read_csv('data/concat_1.csv') df2 = pd.read_csv('data/concat_2.csv') df3 = pd.read_csv('data/concat_3.csv') df1.columns = ['A', 'B', 'C', 'D'] df2.columns = ['E', 'F', 'G', 'H'] df3.columns = ['A', 'C', 'F', 'H'] print(df1) print(df2) print(df3) row_concat = pd.concat([df1, df2, df3]) print(row_concat) print(pd.concat([df1, df2, df3], join='inner')) print(pd.concat([df1,df3], ignore_index=False, join='inner')) df1.index = [0, 1, 2, 3] df2.index = [4, 5, 6, 7] df3.index = [0, 2, 5, 7] print(df1) print(df2) print(df3) col_concat = pd.concat([df1, df2, df3], axis=1) print(col_concat) print(pd.concat([df1, df3], axis=1, join='inner')) 执行结果 $ python3 4-3.py A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 E F G H 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 A C F H 0 a8 b8 c8 d8 1 a9 b9 c9 d9 2 a10 b10 c10 d10 3 a11 b11 c11 d11 A B C D E F G H 0 a0 b0 c0 d0 NaN NaN NaN NaN 1 a1 b1 c1 d1 NaN NaN NaN NaN 2 a2 b2 c2 d2 NaN NaN NaN NaN 3 a3 b3 c3 d3 NaN NaN NaN NaN 0 NaN NaN NaN NaN a4 b4 c4 d4 1 NaN NaN NaN NaN a5 b5 c5 d5 2 NaN NaN NaN NaN a6 b6 c6 d6 3 NaN NaN NaN NaN a7 b7 c7 d7 0 a8 NaN b8 NaN NaN c8 NaN d8 1 a9 NaN b9 NaN NaN c9 NaN d9 2 a10 NaN b10 NaN NaN c10 NaN d10 3 a11 NaN b11 NaN NaN c11 NaN d11 Empty DataFrame Columns: [] Index: [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3] A C 0 a0 c0 1 a1 c1 2 a2 c2 3 a3 c3 0 a8 b8 1 a9 b9 2 a10 b10 3 a11 b11 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 E F G H 4 a4 b4 c4 d4 5 a5 b5 c5 d5 6 a6 b6 c6 d6 7 a7 b7 c7 d7 A C F H 0 a8 b8 c8 d8 2 a9 b9 c9 d9 5 a10 b10 c10 d10 7 a11 b11 c11 d11 A B C D E F G H A C F H 0 a0 b0 c0 d0 NaN NaN NaN NaN a8 b8 c8 d8 1 a1 b1 c1 d1 NaN NaN NaN NaN NaN NaN NaN NaN 2 a2 b2 c2 d2 NaN NaN NaN NaN a9 b9 c9 d9 3 a3 b3 c3 d3 NaN NaN NaN NaN NaN NaN NaN NaN 4 NaN NaN NaN NaN a4 b4 c4 d4 NaN NaN NaN NaN 5 NaN NaN NaN NaN a5 b5 c5 d5 a10 b10 c10 d10 6 NaN NaN NaN NaN a6 b6 c6 d6 NaN NaN NaN NaN 7 NaN NaN NaN NaN a7 b7 c7 d7 a11 b11 c11 d11 A B C D A C F H 0 a0 b0 c0 d0 a8 b8 c8 d8 2 a2 b2 c2 d2 a9 b9 c9 d9 合并多个数据集 4-4.py import pandas as pd person = pd.read_csv('data/survey_person.csv') site = pd.read_csv('data/survey_site.csv') survey = pd.read_csv('data/survey_survey.csv') visited = pd.read_csv('data/survey_visited.csv') print(person) print(site) print(survey) print(visited) visited_subset = visited.iloc[[0, 2, 6], ] o2o_merge = site.merge(visited_subset, left_on='name', right_on='site') print(o2o_merge) m2o_merge = site.merge(visited, left_on='name', right_on='site') print(m2o_merge) ps = person.merge(survey, left_on='ident', right_on='person') vs = visited.merge(survey, left_on='ident', right_on='taken') print(ps) print(vs) 执行结果 $ python3 4-4.py ident personal family 0 dyer William Dyer 1 pb Frank Pabodie 2 lake Anderson Lake 3 roe Valentina Roerich 4 danforth Frank Danforth name lat long 0 DR-1 -49.85 -128.57 1 DR-3 -47.15 -126.72 2 MSK-4 -48.87 -123.40 taken person quant reading 0 619 dyer rad 9.82 1 619 dyer sal 0.13 2 622 dyer rad 7.80 3 622 dyer sal 0.09 4 734 pb rad 8.41 5 734 lake sal 0.05 6 734 pb temp -21.50 7 735 pb rad 7.22 8 735 NaN sal 0.06 9 735 NaN temp -26.00 10 751 pb rad 4.35 11 751 pb temp -18.50 12 751 lake sal 0.10 13 752 lake rad 2.19 14 752 lake sal 0.09 15 752 lake temp -16.00 16 752 roe sal 41.60 17 837 lake rad 1.46 18 837 lake sal 0.21 19 837 roe sal 22.50 20 844 roe rad 11.25 ident site dated 0 619 DR-1 1927-02-08 1 622 DR-1 1927-02-10 2 734 DR-3 1939-01-07 3 735 DR-3 1930-01-12 4 751 DR-3 1930-02-26 5 752 DR-3 NaN 6 837 MSK-4 1932-01-14 7 844 DR-1 1932-03-22 name lat long ident site dated 0 DR-1 -49.85 -128.57 619 DR-1 1927-02-08 1 DR-3 -47.15 -126.72 734 DR-3 1939-01-07 2 MSK-4 -48.87 -123.40 837 MSK-4 1932-01-14 name lat long ident site dated 0 DR-1 -49.85 -128.57 619 DR-1 1927-02-08 1 DR-1 -49.85 -128.57 622 DR-1 1927-02-10 2 DR-1 -49.85 -128.57 844 DR-1 1932-03-22 3 DR-3 -47.15 -126.72 734 DR-3 1939-01-07 4 DR-3 -47.15 -126.72 735 DR-3 1930-01-12 5 DR-3 -47.15 -126.72 751 DR-3 1930-02-26 6 DR-3 -47.15 -126.72 752 DR-3 NaN 7 MSK-4 -48.87 -123.40 837 MSK-4 1932-01-14 ident personal family taken person quant reading 0 dyer William Dyer 619 dyer rad 9.82 1 dyer William Dyer 619 dyer sal 0.13 2 dyer William Dyer 622 dyer rad 7.80 3 dyer William Dyer 622 dyer sal 0.09 4 pb Frank Pabodie 734 pb rad 8.41 5 pb Frank Pabodie 734 pb temp -21.50 6 pb Frank Pabodie 735 pb rad 7.22 7 pb Frank Pabodie 751 pb rad 4.35 8 pb Frank Pabodie 751 pb temp -18.50 9 lake Anderson Lake 734 lake sal 0.05 10 lake Anderson Lake 751 lake sal 0.10 11 lake Anderson Lake 752 lake rad 2.19 12 lake Anderson Lake 752 lake sal 0.09 13 lake Anderson Lake 752 lake temp -16.00 14 lake Anderson Lake 837 lake rad 1.46 15 lake Anderson Lake 837 lake sal 0.21 16 roe Valentina Roerich 752 roe sal 41.60 17 roe Valentina Roerich 837 roe sal 22.50 18 roe Valentina Roerich 844 roe rad 11.25 ident site dated taken person quant reading 0 619 DR-1 1927-02-08 619 dyer rad 9.82 1 619 DR-1 1927-02-08 619 dyer sal 0.13 2 622 DR-1 1927-02-10 622 dyer rad 7.80 3 622 DR-1 1927-02-10 622 dyer sal 0.09 4 734 DR-3 1939-01-07 734 pb rad 8.41 5 734 DR-3 1939-01-07 734 lake sal 0.05 6 734 DR-3 1939-01-07 734 pb temp -21.50 7 735 DR-3 1930-01-12 735 pb rad 7.22 8 735 DR-3 1930-01-12 735 NaN sal 0.06 9 735 DR-3 1930-01-12 735 NaN temp -26.00 10 751 DR-3 1930-02-26 751 pb rad 4.35 11 751 DR-3 1930-02-26 751 pb temp -18.50 12 751 DR-3 1930-02-26 751 lake sal 0.10 13 752 DR-3 NaN 752 lake rad 2.19 14 752 DR-3 NaN 752 lake sal 0.09 15 752 DR-3 NaN 752 lake temp -16.00 16 752 DR-3 NaN 752 roe sal 41.60 17 837 MSK-4 1932-01-14 837 lake rad 1.46 18 837 MSK-4 1932-01-14 837 lake sal 0.21 19 837 MSK-4 1932-01-14 837 roe sal 22.50 20 844 DR-1 1932-03-22 844 roe rad 11.25 参考资料 技术支持qq群144081101 591302926 567351477 钉钉免费群21745728 本文最新版本地址 本文涉及的python测试开发库 谢谢点赞! 本文相关海量书籍下载 源码下载 本文英文版书籍下载

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册