Python execution environment "Google Colaboratory" which can be used as a barrel for data analysis and machine learning, can be used in a browser, and does not require environment construction



The tool called "Jupyter notebook" has been widely used for data analysis and machine learning, which requires Pilot to execute trial and error, because it can execute Python code part by part and check results on the spot. "Colaboratory"Is a tool created based on the Jupyter notebook by adding functions such as" run on the browser "" save the file to Google Drive "" collaborate edit ".

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

When you visit the site of Google Colaboratory, it is on the screen called "Recent Notebook". I will try "Create a new notebook" from the bottom right.


You can select the version of Python to run. This time "PYTHON 3" is chosen.


There is "cell" in the notebook, and pressing the execution button on the left will execute the code in the cell.


There are two kinds of cells, and in addition to the cell that executes the code that came out above, there is also a cell for text. Mark down notation can be used for text cells.


When the cells are executed, numbers are displayed in the order in which they were executed, and the top cell that was executed earlier is displayed as "1". Cells can be executed in any order, not from above, but if you attempt to execute the cell below without executing the cell that defines the variable "a", the variable "a" is not defined "I got an error saying.


Changing the order of execution will be executed properly.


Also, like other Google documents and Google spreadsheets, you can collaborate with others or give you viewing permission from the "Share" button on the top right. Because the execution environment is different, the state of the variable etc is not shared, but the code and its result are shared in real time.


By the way, when you try to analyze data, you will be asked questions such as "How can I enter data?" So, first click "Open a recent notebook" ...


I will read a notebook with various guides.


First of all, about reading external data. There seem to be four ways "Upload local file" "Google Drive" "Google spreadsheet" "Google Cloud Storage".


A sample code is written for each. For local files, import "google.colab.files" and execute "files.upload ()", file selection button will be displayed.


For Google Drive,PyDrive"Or"REST APIYou can use it.


In Google spreadsheets,gspreadIt seems good to use.


Also, spreadsheet dataPandasIt is also possible to read into the DataFrame of Data, and if there is data in the spreadsheet it is likely to begin data analysis easily.


We can also use GCS data which is the storage function of Google Cloud Platform. Although sampling is necessary, it seems that BigQuery data can also be used.


Also, explanation of cells such as "can be executed for each cell ~" ... ...


In the notebook "Charts in Colaboratory"matplotlibYaseabornInformation on how to write charts with Gyroscope, such as guide, information that may be useful when analyzing data in Python is also listed.


There was also a guide of markdown notation. Colaboratory said that unlike other sites, LaTeX can be used to fill mathematical expressions. Collaborative work seems to proceed more smoothly because you can describe mathematical expressions and implementations at the same time.

in Review,   Software,   Web Service,   Web Application, Posted by log1d_ts