划痕实验 迁移面积自动统计_从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,一经查实,立即删除!

相关文章

英法德三门语言同时达到c1,【分享】插翅而飞的孩子(转载)

微信转来的,觉得发人深思,转来这里插翅而飞的孩子(一)开篇一:让孩子拥有一双丰满的翅膀。作者简介:英华兰的Dr.Bing,德国儿童教育学博士,数字媒体硕士和计算机软件工程本科。精通英法德三门语言,从事儿童语…

数据库建表赋予权限语句

sqlplus /nologconn / as sysdba//创建临时表空间create temporary tablespace zfmi_temptempfile D:\oracle\oradata\zfmi\zfmi_temp.dbf size 32m autoextend on next 32m maxsize 2048mextent management local;//tempfile参数必须有//创建数据表空间create tablespace zfmi…

day03 基本数据类型

1.什么是数据类型 变量值即我们 存放的数据 ,数据类型及变量值的类型 2.变量值为何要区分类型 因为变量值使用记录现实世界中事物的特征,针对不同的特征就应该用不同类型的值去标识 3.如何应用数据类型 一 数据类型: 1.整型int :…

美国移民局的I797表原件和I129表是什么呢

I-129表,Petition for a Non-immigrant Worker,即非移民工作许可申请表I797 表 ,Original L1-1A approval notice L1签证批准通过通知表L-1签证的申请程序1. L-1签证的申请必须首先由准备调派雇员的外国母公司在美国的分支机构向移民局提出陈情申请。这些…

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

数据开放 数据集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…

单选按钮android服务器,android – 如何在radiogroup中将单选按钮设置...

我已经动态创建了RadioGroup和RadioButton,如下所示:RadioGroup radioGroup new RadioGroup(context);RadioButton radioBtn1 new RadioButton(context);RadioButton radioBtn2 new RadioButton(context);RadioButton radioBtn3 new RadioButton(context);radio…

导入DMP文件过程

导入DMP文件过程 --释放重名表空间 drop tablespace hxgr including contents and datafiles cascade constraints; --建立表空间 create tablespace hxgr logging datafile D:\oracle\oradata\hxgr\hxgr.dbf size 100m autoextend on next 32m maxsize 2048m extent manage…

string 转化 xml,并找到指定节点及节点值

//这是一个符合xml格式的字符串string xml "<xmn> <people><name>zs</name><age>22</age></people> <people><name>ls</name><age>23</age></people> </xmn>";//将string 转化…

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

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

Servlet+JSP

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

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

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

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

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

对象-检测属性

<h3>判断某个属性是否存在于某个对象中&#xff1b;</h3><ol><li>in&#xff1a;检查一个属性是否属于某个对象&#xff0c;包括继承来的属性&#xff1b;<pre>var person {name:yourname, age:10};console.log(name in person); //trueconsole…

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

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

洛谷——P2018 消息传递

P2018 消息传递 题目描述 巴蜀国的社会等级森严&#xff0c;除了国王之外&#xff0c;每个人均有且只有一个直接上级&#xff0c;当然国王没有上级。如果A是B的上级&#xff0c;B是C的上级&#xff0c;那么A就是C的上级。绝对不会出现这样的关系&#xff1a;A是B的上级&#xf…

axios异步请求数据的简单使用

使用Mock模拟好后端数据之后&#xff08;Mock模拟数据的使用参考&#xff1a;https://segmentfault.com/a/11...&#xff09;&#xff0c;就需要尝试请求加载数据了。数据请求选择了axios&#xff0c;现在都推荐使用axios。 axios&#xff08;https://github.com/axios/axios&a…

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

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

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

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封了&#xff0c;因此目前无法使用LR8.1版本&#xff0c;包括该版本的中文补丁。 破解思路&#xff1a;由于软件的加密程序和运行的主程序是分开的&#xff0c;因此可以使用7.8的加密程序覆盖8.1中的加密程序&#xff0c;这样老的7.8和…

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

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