划痕实验 迁移面积自动统计_从Jupyter迁移到合作实验室

划痕实验 迁移面积自动统计

If you want to use Google Colaboratory to perform your data analysis, for building data pipelines and data visualizations, here is the beginners’ guide to migrate from one tool to the other.

如果您想使用Google Colaboratory进行数据分析,以建立数据管道和数据可视化,这是初学者指南,可以从一种工具迁移到另一种工具。

为什么要迁移? (Why migrate?)

To be honest, I came to using Colab, since I needed an iOS-friendly tool without a long installation adventure. The iOS version of Colab — actually, the iOS version of any browser — has a couple of problems, but I am currently quite satisfied.

老实说,我之所以开始使用Colab,是因为我需要一个iOS友好型工具,而无需进行长时间的安装。 iOS版的Colab(实际上是任何浏览器的iOS版)都有两个问题,但我目前非常满意。

The article is based upon my MacOS experience with Colab and the screenshots are also originate from MacOS.

本文基于我对Colab的MacOS经验,并且屏幕截图也来自MacOS。

创建一个Google帐户 (Create a Google account)

This is the first step, since you are going to work in a part of a Google ecosystem. Google Colaboratory (further referred to as Colab) runs in a cloud. You will use it in a browser.

这是第一步,因为您将要在Google生态系统的一部分中工作。 Google合作实验室(又称为Colab)在云中运行。 您将在浏览器中使用它。

下载谷歌浏览器 (Download Google Chrome)

Although the ultimate part of the world population is using Chrome (just kidding!), I still want to add this notion here. To access your Colab working space, you will need to log in to your Google account every time.

尽管世界人口的最终部分是使用Chrome(开个玩笑!),但我仍然想在此添加这个概念。 要访问您的Colab工作空间,您每次都需要登录到您的Google帐户。

In Chrome, you can stay logged and manage other spaces that you can integrate with Colab.

在Chrome中,您可以保持登录状态并管理可以与Colab集成的其他空间。

首次访问Colab (Access Colab for the first time)

You will need to open the following URL in your browser:

您将需要在浏览器中打开以下URL:

https://colab.research.google.com/

https://colab.research.google.com/

Or just type the “google colab” in the Google search engine.

或者,只需在Google搜索引擎中输入“ google colab”。

After you’ve created any Colab files (I’ll go through it in the next step) you will be also able to access your working space from Google Drive.

创建任何Colab文件后(我将在下一步中进行介绍),您还可以从Google云端硬盘访问您的工作空间。

上传您的Jupyter笔记本 (Upload your Jupyter notebooks)

With Colab, you are not using your Jupyter notebooks locally. You will need to add them to your Google Drive. You’ll get a Google Drive automatically when you create your Google account.

使用Colab,您将不会在本地使用Jupyter笔记本。 您需要将它们添加到您的Google云端硬盘。 创建Google帐户后,您会自动获得一个Google云端硬盘。

Image for post
The pop-up window you see after opening the Colab URL: your recently used notebooks
打开Colab URL后看到的弹出窗口:您最近使用过的笔记本

The first two are the official documentation.

前两个是官方文档。

Image for post
The upload tab in the same pop-up window: upload your Jupyter notebooks
同一弹出窗口中的上载选项卡:上载Jupyter笔记本

Exactly, you do not need to convert your notebooks at all!

确实,您根本不需要转换笔记本!

Colab is built upon Jupyter and the format is the same. Pretty cool, if you decide to get back to the local Jupyter again!

Colab基于Jupyter构建,并且格式相同。 如果您决定再次回到当地的Jupyter,那就太酷了!

An upload form will appear each time you’ll open the Colab URL.

每次您打开Colab URL时,都会出现一个上传表单。

再次访问Colab (Access Colab again)

As I mentioned before, once you have any notebooks in there, a Colab folder will be automatically created in your Google Drive. The icon will have a yellow color. You can go to the folder, open it, double-click on a notebook, and then on “Open with Google Colaboratory”:

如前所述,一旦您有任何笔记本,就会在Google云端硬盘中自动创建一个Colab文件夹。 图标将显示为黄色。 您可以转到文件夹,将其打开,双击笔记本,然后单击“使用Google Colaboratory打开”:

Image for post
Colab Notebooks folder in your Google Drive space
Google云端硬盘空间中的Colab Notebooks文件夹
Image for post
Select and a notebook and double-click on it
选择一个笔记本,然后双击它
Image for post
Click “Open with Colab” on in the top middle (sometimes it appears in the bottom, too)
单击顶部中间的“ Open with Colab”(有时也显示在底部)

If you entry point in the Colab URL, then the list of your recently used notebooks will pop up. You can switch to uploading notebooks, or pick them from you Google Drive, or even from you GitHub. Read more on GitHub here.

如果您在Colab URL中输入入口,则将弹出您最近使用过的笔记本的列表。 您可以切换到上传笔记本,也可以从Google云端硬盘甚至是GitHub中选择笔记本。 了解更多关于GitHub上这里 。

Image for post
Opening your notebooks stored in Google Drive and on GitHub
打开存储在Google云端硬盘和GitHub中的笔记本

开始工作 (Start working)

The interface is pretty much the same. You access the usual features through the panel atop of the notebook.

界面几乎相同。 您可以通过笔记本顶部的面板访问常规功能。

Image for post
Inside the notebook: the top panel
笔记本内部:顶部面板

You have a table of the contents on the left side and an overview of your files.

您在左侧有一个目录表,并提供了文件概述。

Image for post
Easy navigate in your notebook: the table of the contents
在笔记本中轻松浏览:目录

But …

但是...

安装套件 (Installing packages)

You’ll soon notice that the import command sometimes fails.

您很快就会注意到,导入命令有时会失败。

Colab has pandas, but for less popular packages you’ll need a pip installation. Since you do not have access to the respective Terminal, — remember, Colab runs in a cloud! — you’ll have to type the command inside the notebook.

Colab有熊猫,但是对于不太受欢迎的软件包,您需要安装pip。 由于您无权访问各自的终端,请记住,Colab在云中运行! —您必须在笔记本电脑中键入命令。

And put an exclamation mark before pip:

并在点子前加上一个感叹号:

!pip install nest_asyncioimport nest_asyncio

Do not forget to import the packages you’ve installed.

不要忘记导入已安装的软件包。

插入外部数据 (Inserting external data)

从本地硬盘上传 (Upload from your local hard drive)

You’ll have to use a native workaround to import data from the files stored on your PC locally.

您必须使用本机解决方法从本地存储在PC中的文件中导入数据。

You will have to use an upload package that Google created for you.

您将必须使用Google为您创建的上传包。

Just go ahead and run the code to be asked to select your files:

只需继续运行并运行要求您选择文件的代码即可:

from google.colab import filesuploaded = files.upload()
Image for post
Choose files to upload from your local drive
选择要从本地驱动器上载的文件
Image for post
Results of your upload: ‘local test.txt” is now stored on your virtual machine
上传结果:“ local test.txt”现在存储在虚拟机上

Then you can refer to this file in your code, for instance:

然后,您可以在代码中引用此文件,例如:

with open(‘local test.txt’, ‘r’, newline=’\r\n’) as f:     print(f.read().splitlines())
Image for post
Data from a .TXT file
.TXT文件中的数据

You can replace read().splitlines()) with any other method you prefer.

您可以使用您喜欢的任何其他方法替换read()。splitlines())。

If you want to upload the next one, you can just re-run the upload code.

如果您要上传下一个,只需重新运行上传代码即可。

Of course, you can upload .CSV and easily turn it into a data frame:

当然,您可以上传.CSV并将其轻松转换为数据框:

Image for post
The same procedure to upload a .CSV file …
上载.CSV文件的步骤相同...
Image for post
… which you easily convert into a data frame!
…您可以轻松将其转换为数据框!

In this regard, there is no difference between handling the files in Jupyter and in Colab. In Colab you only add the native import command to call the pop-up window to access your file system from the notebook.

在这方面,在Jupyter和Colab中处理文件没有区别。 在Colab中,您仅添加本机导入命令来调用弹出窗口以从笔记本计算机访问文件系统。

连接到Google云端硬盘 (Connect to Google Drive)

Basically, you can import/export data from/to Google Drive in the form of either TXT or CSV. You do not have to install a Google Drive app. You are going to connect to it in the browser.

基本上,您可以使用TXT或CSV格式从Google云端硬盘导入数据/将数据导出到Google云端硬盘。 您不必安装Google云端硬盘应用。 您将在浏览器中连接到它。

from google.colab import drivedrive.mount(‘/content/drive’)
Image for post
Filling in the form to connect to Google Drive
填写表格以连接到Google云端硬盘

Click on the URL, click “Allow” and then copy the authorization code. Paste the code into the long cell and click “Enter”. The connection is there.

单击URL,单击“允许”,然后复制授权代码。 将代码粘贴到长单元格中,然后单击“ Enter”。 连接在那里。

You can read more about it in the official documentation.

您可以在官方文档中了解更多信息。

The same open command works to insert data from a file stored in the Drive. You only need to add the Google Drive path:

相同的open命令可从存储在驱动器中的文件中插入数据。 您只需要添加Google云端硬盘路径:

Image for post
Accessing the same txt-data in Google Drive
在Google云端硬盘中访问相同的txt数据

使用Google云端硬盘 (Use Google Drive Sheets)

Google developed a python package to read data from Google Sheets.

Google开发了一个python包来从Google表格中读取数据。

!pip install — upgrade gspreadfrom google.colab import authauth.authenticate_user()import gspreadfrom oauth2client.client import GoogleCredentialsgc = gspread.authorize(GoogleCredentials.get_application_default())worksheet = gc.open(‘grandresult_2020–07–29 13:50:19.096165’).sheet1rows = worksheet.get_all_values()grandresult = pandas.DataFrame.from_records(rows)

You install it over the “cloud” pip, then get an authorization to use Sheets. Be carefully, this connection and the previous one (that you launch with drive.mount) are separated.

您通过“云”点安装它,然后获得使用表格的授权。 请注意,此连接与上一个连接(使用drive.mount启动)分开。

You pick up your file and then the first sheet: “sheet1” stands for the sheet number one and not a name of your sheet!

您先提取文件,然后提取第一个工作表:“ sheet1”代表工作表编号1,而不是工作表名称!

You can directly start with pandas.

您可以直接从熊猫开始。

通过Python本机包获取数据 (Fetching data by means of Python native packages)

If you download data from an API request, or parse an HTML with a BeautifulSoup, or any other native Python package, then it works in a usual way.

如果您从API请求中下载数据,或者使用BeautifulSoup或任何其他本机Python包解析HTML,那么它通常会起作用。

汇出资料 (Exporting data)

作为.TXT (As .TXT)

You can either export data by replacing the read command with the write command and adding a download line like that:

您可以通过将read命令替换为write命令并添加如下下载行来导出数据:

df = df.to_string() #to convert your data frame into .TXT filewith open(‘local test.txt’, ‘w’) as f:     f.write(df)files.download(‘local text.txt’)

作为.CSV (As .CSV)

Or you can download a .CSV:

或者,您可以下载.CSV:

df.to_csv(‘local test.csv’)files.download(‘local test.csv’)

作为Google表格 (As a Google Sheet)

This code snippet allows to save a data frame into a Google Sheet:

此代码段允许将数据框保存到Google表格中:

from gspread_dataframe import set_with_dataframegc.create(‘Title of your Google Sheet’)sheet = gc.open(‘Title of your Google Sheet’).sheet1set_with_dataframe(‘Title of your Google Sheet’, df)

iOS和数据导入/导出 (iOS and data import/export)

We do not have the usual file path to save anything in the iOS file system. This makes exporting your data for storing it locally a ghost feature.

我们没有通常的文件路径将任何内容保存在iOS文件系统中。 这使得导出数据以将其存储在本地成为重影功能。

In general, if you download any file from Safari on an iOS device, you’ll have to access the saved files directly from the Safari by clicking on the icon:

通常,如果您在iOS设备上从Safari下载任何文件,则必须直接通过以下图标从Safari访问保存的文件:

Image for post
You can pick up your downloaded files only inside Safari and only during the current session
您只能在Safari中并且仅在当前会话期间才能下载下载的文件

Although many recent iOS devices do have a file browser, in my case, I could not find the data I’ve exported from a Colab notebook as a .CSV.

尽管最近的许多iOS设备确实具有文件浏览器,但就我而言,我找不到从Colab笔记本中导出为.CSV的数据。

So, I stick to the Google Sheet or TXT method.

因此,我坚持使用Google Sheet或TXT方法。

为什么实际上叫Colab? (Why is it actually called Colab?)

Now, I want to mention a couple of features that were supposed to make Colab a better breed.

现在,我想谈谈一些应该使Colab成为更好品种的功能。

  • You can use it instead of arranging a server to run complex pipelines in the Jupyter notebook format.

    您可以使用它代替安排服务器以Jupyter笔记本格式运行复杂的管道。
  • You can access it from everywhere, as long as you have a network coverage.

    只要您具有网络覆盖范围,就可以从任何地方访问它。
  • For some data manipulations, it is faster, even without a Pro membership.

    对于某些数据操作,即使没有Pro成员身份,它也更快。

But, mainly, it was designed to let more than one person to work on the same notebook and communicate with co-workers without leaving the notebook and involving some additional communication channel.

但是,主要是,它的设计目的是让一个以上的人可以在同一个笔记本上工作并与同事进行交流,而不必离开笔记本并涉及一些其他的交流渠道。

评论细胞 (Commenting on the cells)

This small icon stands for the commenting function. You can leave comments for your co-workers, but you do not have to include them into the code with # on the beginning or create an additional text cell.

这个小图标代表注释功能。 您可以为同事留下评论,但不必将其包含在代码中,并以#开头或创建其他文本单元格。

Image for post
Add comment to a cell
在单元格中添加评论

You can edit and delete your comments. After the issues you were asking about in your note were solved press “Resolve” to hide the comment thread.

您可以编辑和删除您的评论。 解决了您在便笺中询问的问题后,请按“解决”以隐藏评论主题。

Image for post
Edit or delete your comment
编辑或删除您的评论
Image for post
Resolve a comment thread: it will disappear.
解决评论线程:它将消失。

This is easier if you just want to leave a note that is only a temporary one and does not belong into the final code.

如果您只想留下一个暂时的注释,并且不属于最终代码,则这样会更容易。

另一个精美的UI功能:更改主题 (Another fancy UI feature: changing the theme)

It got more complicated with the packages, but there is a compensation for it: you do not need any inline command to switch the color theme!

这些软件包变得更加复杂,但是有一个补偿:您不需要任何内联命令来切换颜色主题!

Image for post
Change the notebook theme: accessible from the settings menu on the top right (the gear icon)
更改笔记本主题:可从右上角的设置菜单访问(齿轮图标)

Unfortunately, only three themes — dark, light, and adaptive — are currently available. Less choice, less doubts!

不幸的是,目前只有三个主题:黑暗,明亮和自适应。 更少的选择,更少的疑问!

改变语言 (Changing the language)

The last feature I had to refer to quite often, especially, while writing this manual.

我不得不经常参考的最后一个功能,特别是在编写本手册时。

A Colab notebook will be shown in your local language, regardless of the language you’ve set for your entire Google profile.

无论您为整个Google个人资料设置了哪种语言,都会以您的本地语言显示Colab笔记本。

There is one single button in Colab, always in the same place, under the “Help” section in the top panel:

在Colab中,只有一个按钮始终位于同一位置,位于顶部面板的“帮助”部分下:

Image for post
Switching to English from any other world language
从其他世界语言切换为英语

It is always the last one in the drop down.

它始终是下拉列表中的最后一个。

简短的后记 (A short afterword)

You will definitely discover even more interesting features and new horizons in using Colab. I’ll stop here, since this is the ultimate list I found important so far.

使用Colab一定会发现更多有趣的功能和新视野。 我将在这里停止,因为这是到目前为止我发现很重要的最终清单。

翻译自: https://medium.com/swlh/migrating-from-jupyter-to-colaboratory-2888332d57a7

划痕实验 迁移面积自动统计

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388518.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

数据开放 数据集_除开放式清洗之外:叙述是开放数据门户的未来吗?

数据开放 数据集There is growing consensus in the open data community that the mere release of open data — that is data that can be freely accessed, remixed, and redistributed — is not enough to realize the full potential of openness. Successful open data…

ios android 交互 区别,很多人不承认:iOS的返回交互,对比Android就是反人类。

宁之的奥义2020-09-21 10:54:39点灭只看此人举报给你解答:美国人都是左撇子,所以他们很方便🐶给你解答:美国人都是左撇子,所以他们很方便🐶亮了(504)回复查看评论(19)回忆的褶皱楼主2020-09-21 11:01:01点灭…

Servlet+JSP

需要说明的是,其实工具的版本不是主要因素,所以我下面忽略版本。 你能搜到这篇文章,说明你已经知道怎么部署Tomcat,并运行自己的网页了。 但是,我们知道,每次修改源文件,我们总得手工把文件co…

正态分布高斯分布泊松分布_正态分布:将数据转换为高斯分布

正态分布高斯分布泊松分布For detailed implementation in python check my GitHub repository.有关在python中的详细实现,请查看我的GitHub存储库。 介绍 (Introduction) Some machine learning model like linear and logistic regression assumes a Gaussian di…

BABOK - 开篇:业务分析知识体系介绍

本文更新版已挪至 http://www.zhoujingen.cn/itbang/328.html ---------------------------------------------- 当我们作项目时,下面这张图很多人都明白,从计划、构建、测试、部署实施后发现提供的方案并不能真正解决用户的问题,那么我们是…

黑苹果 wifi android,动动手指零负担让你的黑苹果连上Wifi

动动手指零负担让你的黑苹果连上Wifi2019-12-02 10:08:485点赞36收藏4评论购买理由黑苹果Wifi是个头疼的问题,高“贵”的原机Wifi蓝牙很贵,比如我最近偶然得到的BCM94360CS2,估计要180。稍微便宜的一点的,搞各种ID,各种…

float在html语言中的用法,float属性值包括

html中不属于float常用属性值的是float常用的值就三个:left\right\none。没有其他的值了。 其中none这个值是默认的,所以一般不用写。css中float属性有几种用法?值 描述left 元素向左浮动。 right 元素向右浮动。 none 默认值。元素不浮动,并…

它们是什么以及为什么我们不需要它们

Once in a while, when reading papers in the Reinforcement Learning domain, you may stumble across mysterious-sounding phrases such as ‘we deal with a filtered probability space’, ‘the expected value is conditional on a filtration’ or ‘the decision-mak…

LoadRunner8.1破解汉化过程

LR8.1版本已经将7.8和8.0中通用的license封了,因此目前无法使用LR8.1版本,包括该版本的中文补丁。 破解思路:由于软件的加密程序和运行的主程序是分开的,因此可以使用7.8的加密程序覆盖8.1中的加密程序,这样老的7.8和…

TCP/IP网络编程之基于TCP的服务端/客户端(二)

回声客户端问题 上一章TCP/IP网络编程之基于TCP的服务端/客户端(一)中,我们解释了回声客户端所存在的问题,那么单单是客户端的问题,服务端没有任何问题?是的,服务端没有问题,现在先让…

谈谈iOS获取调用链

本文由云社区发表iOS开发过程中难免会遇到卡顿等性能问题或者死锁之类的问题,此时如果有调用堆栈将对解决问题很有帮助。那么在应用中如何来实时获取函数的调用堆栈呢?本文参考了网上的一些博文,讲述了使用mach thread的方式来获取调用栈的步…

python 移动平均线_Python中的移动平均线

python 移动平均线There are situations, particularly when dealing with real-time data, when a conventional average is of little use because it includes old values which are no longer relevant and merely give a misleading impression of the current situation.…

html5字体的格式转换,font字体

路由器之家网今天精心准备的是《font字体》,下面是详解!html中的标签是什么意思HTML提供了文本样式标记,用来控制网页中文本的字体、字号和颜色,多种多样的文字效果可以使网页变得更加绚丽。其基本语法格式:文本内容fa…

红星美凯龙牵手新潮传媒抢夺社区消费市场

瞄准线下流量红利,红星美凯龙牵手新潮传媒抢夺社区消费市场 中新网1月14日电 2019年1月13日,红星美凯龙和新潮传媒战略合作发布会在北京召开,双方宣布建立全面的战略合作伙伴关系。未来,新潮传媒的梯媒产品将入驻红星美凯龙的全国…

机器学习 啤酒数据集_啤酒数据集上的神经网络

机器学习 啤酒数据集Artificial neural networks (ANNs), usually simply called neural networks (NNs), are computing systems vaguely inspired by the biological neural networks that constitute animal brains.人工神经网络(ANN)通常简称为神经网络(NNs),是…

ER TO SQL语句

ER TO SQL语句的转换,在数据库设计生命周期的位置如下所示。 一、转换的类别 从ER图转化得到关系数据库中的SQL表,一般可分为3类: 1)转化得到的SQL表与原始实体包含相同信息内容。该类转化一般适用于: 二元“多对多”关…

dede 5.7 任意用户重置密码前台

返回了重置的链接,还要把&amp删除了,就可以重置密码了 结果只能改test的密码,进去过后,这个居然是admin的密码,有点头大,感觉这样就没有意思了 我是直接上传的一句话,用菜刀连才有乐趣 OK了…

nasa数据库cm1数据集_获取下一个地理项目的NASA数据

nasa数据库cm1数据集NASA provides an extensive library of data points that they’ve captured over the years from their satellites. These datasets include temperature, precipitation and more. NASA hosts this data on a website where you can search and grab in…

r语言处理数据集编码_在强调编码语言或工具之前,请学习这3个基本数据概念

r语言处理数据集编码重点 (Top highlight)I got an Instagram DM the other day that really got me thinking. This person explained that they were a data analyst by trade, and had years of experience. But, they also said that they felt that their technical skill…

HTML和CSS面试问题总结,html和css面试总结

html和cssw3c 规范结构化标准语言样式标准语言行为标准语言1) 盒模型常见的盒模型有w3c盒模型(又名标准盒模型)box-sizing:content-box和IE盒模型(又名怪异盒模型)box-sizing:border-box。标准盒子模型:宽度内容的宽度(content) border padding margin低版本IE盒子…