databricks

by Shubhi Asthana

通过Shubhi Asthana

如何开始使用Databricks (How to get started with Databricks)

When I started learning Spark with Pyspark, I came across the Databricks platform and explored it. This platform made it easy to setup an environment to run Spark dataframes and practice coding. This post contains some steps that can help you get started with Databricks.

当我开始使用Pyspark学习Spark时,我遇到了Databricks平台并进行了探索。 通过该平台,可以轻松设置运行Spark数据帧和练习编码的环境。 这篇文章包含一些步骤,可以帮助您开始使用Databricks。

Databricks is a platform that runs on top of Apache Spark. It conveniently has a Notebook systems setup. One can easily provision clusters in the cloud, and it also incorporates an integrated workspace for exploration and visualization.

Databricks是一个在Apache Spark之上运行的平台。 它方便地具有笔记本电脑系统设置。 可以轻松地在云中配置群集,并且它还集成了用于探索和可视化的集成工作区。

You can also schedule any existing notebook or locally developed Spark code to go from prototype to production without re-engineering.

您还可以计划任何现有的笔记本电脑或本地开发的Spark代码,从原型制作到生产,而无需重新设计。

1. 设置一个Databricks帐户 (1. Setup a Databricks account)

To get started with the tutorial, navigate to this link and select the free Community Edition to open your account. This option has single cluster with up to 6 GB free storage. It allows you to create a basic Notebook. You’ll need a valid email address to verify your account.

要开始使用本教程,请导航至此链接,然后选择免费的Community Edition打开您的帐户。 此选项具有最多6 GB可用存储的单个群集。 它允许您创建一个基本的Notebook。 您需要一个有效的电子邮件地址来验证您的帐户。

You will observe this screen once you successfully log in to your account.

成功登录帐户后,您将看到此屏幕。

2. 创建一个新集群 (2. Creating a new Cluster)

We start with creating a new cluster to run our programs on. Click on “Cluster” on the main page and type in a new name for the cluster.

我们首先创建一个新的集群来运行我们的程序。 单击主页上的“群集”,然后为群集键入一个新名称。

Next, you need to select the “Databricks Runtime” version. Databricks Runtime is a set of core components that run on clusters managed by Databricks. It includes Apache Spark, but also adds a number of components and updates to improve the usability and performance of the tool.

接下来,您需要选择“ Databricks Runtime”版本。 Databricks Runtime是一组在Databricks管理的群集上运行的核心组件。 它包括Apache Spark,但还添加了许多组件和更新以改善该工具的可用性和性能。

You can select any Databricks Runtime version — I have selected 3.5 LTS (includes Apache Spark 2.2.1, Scala 2.11). You also have a choice between Python 2 and 3.

您可以选择任何Databricks Runtime版本-我选择了3.5 LTS(包括Apache Spark 2.2.1,Scala 2.11)。 您还可以在Python 2和3之间进行选择。

It’ll take a few minutes to create the cluster. After some time, you should be able to see an active cluster on the dashboard.

创建集群需要几分钟。 一段时间后,您应该能够在仪表板上看到活动的集群。

3. 创建一个新的笔记本 (3. Creating a new Notebook)

Let’s go ahead and create a new Notebook on which you can run your program.

让我们继续创建一个新的Notebook,您可以在其上运行程序。

From the main page, hit “New Notebook” and type in a name for the Notebook. Select the language of your choice — I chose Python here. You can see that Databricks supports multiple languages including Scala, R and SQL.

在主页上,单击“新笔记本”,然后输入笔记本的名称。 选择您选择的语言-我在这里选择了Python。 您可以看到Databricks支持多种语言,包括Scala,R和SQL。

Once the details are entered, you will observe that the layout of the notebook is very similar to the Jupyter notebook. To test the notebook, let’s import pyspark.

输入详细信息后,您会发现笔记本的布局与Jupyter笔记本非常相似。 要测试笔记本,让我们导入pyspark。

The command ran in 0.15 seconds and also gives the cluster name on which it is running. If there are any errors in the code, it would show below the cmd box.

该命令运行了0.15秒,并且还给出了运行命令的集群名称。 如果代码中有任何错误,它将显示在cmd框下方。

You can hit the keyboard icon on the top right corner of the page to see operating system-specific shortcuts.

您可以点击页面右上角的键盘图标来查看特定于操作系统的快捷方式。

The most important shortcuts here are:

这里最重要的快捷方式是:

  • Shift+Enter to run a cellShift + Enter键运行单元格
  • Ctrl+Enter keeps running the same cell without moving to the next cellCtrl + Enter保持运行相同的单元格,而无需移动到下一个单元格

Note these shortcuts are for Windows. You can check the OS-specific shortcuts for your OS on the keyboard icon.

请注意,这些快捷方式适用于Windows。 您可以在键盘图标上检查操作系统特定于操作系统的快捷方式。

4. 将数据上传到Databricks (4. Uploading data to Databricks)

Head over to the “Tables” section on the left bar, and hit “Create Table.” You can upload a file, or connect to a Spark data source or some other database.

转到左侧栏上的“表格”部分,然后点击“创建表格”。 您可以上传文件,或连接到Spark数据源或其他数据库。

Let’s upload the commonly used iris dataset file here (if you don’t have the dataset, use this link )

让我们在这里上传常用的虹膜数据集文件(如果您没有数据集,请使用此链接 )

Once you upload the data, create the table with a UI so you can visualize the table, and preview it on your cluster. As you can see, you can observe the attributes of the table. Spark will try to detect the datatype of each of the columns, and lets you edit it too.

上载数据后,使用UI创建表,以便可以可视化表并在集群上预览。 如您所见,您可以观察表的属性。 Spark将尝试检测每列的数据类型,并让您对其进行编辑。

Now I need to put headers for the columns, so I can identify each column by their header instead of _c0, _c1 and so on.

现在,我需要为各列添加标题,以便可以通过其标题而不是_c0_c1等等来标识每一列。

I put their headers as Sepal Length, Sepal Width, Petal Length, Petal Width and Class. Here, Spark detected the datatype of the first four columns incorrectly as a String, so I changed it to the desired datatype — Float.

我把它们的标题设置为“分隔长度”,“分隔宽度”,“花瓣长度”,“花瓣宽度”和“类”。 在这里,Spark错误地将前四列的数据类型检测为String,因此我将其更改为所需的数据类型-Float。

5. 如何从笔记本电脑访问数据 (5. How to access data from Notebook)

Spark is a framework that can be used to analyze big data using SQL, machine learning, graph processing or real-time streaming analysis. We will be working with SparkSQL and Dataframes in this tutorial.

Spark是一个框架,可用于使用SQL,机器学习,图形处理或实时流分析来分析大数据。 在本教程中,我们将使用SparkSQL和Dataframes。

Let’s get started with working with the data on the Notebook. The data that we have uploaded is now put in tabular format.We require a SQL query to read the data and put it in a dataframe.

让我们开始使用笔记本上的数据。 现在,我们已上传的数据以表格格式放置。我们需要一个SQL查询来读取数据并将其放置在数据框中。

Type df = sqlContext.sql(“SELECT * FROM iris_data”) to read iris data into a dataframe.

类型df = sqlContext.sql(“SELECT * FROM iris_data”) 将虹膜数据读入数据帧。

To view the first five rows in the dataframe, I can simply run the command:

要查看数据框中的前五行,我可以简单地运行以下命令:

display(df.limit(5))

display(df.limit(5))

Notice a Bar chart icon at the bottom. Once you click, you can view the data that you have imported into Databricks. To view the bar chart of complete data, rundisplay(df) instead of display(df.limit(5)).

注意底部的条形图图标。 单击后,您可以查看已导入到Databricks中的数据。 要查看完整数据的条形图,请运行display(df)而不是display(df.limit(5))

The dropdown button allows you to visualize the data in different charts like bar, pie, scatter, and so on. It also gives you plot options to customize the plot and visualize specific columns only.

下拉按钮使您可以可视化不同图表中的数据,如条形图,饼图,散点图等。 它还提供了绘图选项,以自定义绘图并仅显示特定的列。

You can also display matplotlib and ggplot figures in Databricks. For a demonstration, see Matplotlib and ggplot in Python Notebooks.

您还可以在Databricks中显示matplotlib和ggplot数字。 有关演示,请参阅Python Notebooks中的Matplotlib和ggplot 。

To view all the columns of the data, simply type df.columns

要查看数据的所有列,只需键入df.columns

To count how many rows total there are in the Dataframe (and see how long it takes to a full scan from remote disk/S3), run df.count().

要计算数据帧中总共有多少行(并查看从远程磁盘/ S3进行全面扫描所花费的时间),请运行df.count()

6.将Spark数据框转换为Pandas数据框。 (6. Converting a Spark dataframe to a Pandas dataframe.)

Now if you are comfortable using pandas dataframes, and want to convert your Spark dataframe to pandas, you can do this by putting the command

现在,如果您习惯使用pandas数据框,并且想要将Spark数据框转换为pandas,则可以通过以下命令来完成此操作

import pandas as pdpandas_df=df.to_pandas()

Now you can use pandas operations on the pandas_df dataframe.

现在,您可以在pandas_df数据帧上使用pandas操作。

7.查看Spark UI (7. Viewing the Spark UI)

The Spark UI contains a wealth of information needed for debugging Spark jobs. There are a bunch of great visualizations, so let’s view them in a gist.

Spark UI包含调试Spark作业所需的大量信息。 有很多很棒的可视化效果,所以让我们大致了解一下它们。

To go to Spark UI, you need to go to the top of the page where there are some menu options like “File,” “View,” “Code,” “Permissions,” and others. You will find the name of the cluster at the top next to “Attached” and a dropdown button next to it. Hit the dropdown button and select “View Spark UI.” A new tab will open up with the lots of information on your Notebook.

要转到Spark UI,您需要转到页面顶部,这里有一些菜单选项,如“文件”,“视图”,“代码”,“权限”等。 您将在“已附加”旁边的顶部找到集群的名称,并在其旁边找到一个下拉按钮。 点击下拉按钮,然后选择“查看Spark UI”。 一个新的选项卡将打开,其中包含笔记本电脑上的大量信息。

The UI view gives plenty of information on each job executed on the cluster, stages, environment, and SQL queries executed. This UI can be helpful for users to debug their applications. Also, this UI gives a good visualization on Spark streaming statistics. To learn in more detail about each aspect of the Spark UI, refer to this link.

UI视图提供了有关在集群上执行的每个作业,阶段,环境和执行SQL查询的大量信息。 该UI有助于用户调试其应用程序。 此外,此UI还提供了关于Spark流统计的良好可视化效果。 要详细了解Spark UI的各个方面,请参阅此链接 。

Once you are done with the Notebook, you can go ahead and publish it or export the file in different file formats, such that somebody else can use it using a unique link. I have attached my Notebook in HTML format.

使用笔记本电脑完成操作后,您可以继续发布并以不同的文件格式导出文件,以便其他人可以通过唯一链接使用它。 我已经以HTML格式附加了我的笔记本 。

结语 (Wrapping up)

This is a short overview on how you can get started with Databricks quickly and run your programs. The advantage of using Databricks is that it offers an end-to-end service for building analytics, data warehousing, and machine learning applications. The entire Spark cluster can be managed, monitored, and secured using a self-service model of Databricks.

这是有关如何快速开始使用Databricks并运行程序的简短概述。 使用Databricks的优势在于,它为构建分析,数据仓库和机器学习应用程序提供了端到端服务。 可以使用Databricks的自助模型来管理,监视和保护整个Spark集群。

Here are some interesting links for Data Scientists and for Data Engineers. Also, here is a tutorial which I found very useful and is great for beginners.

这是数据科学家和数据工程师的一些有趣链接。 另外,这是我发现非常有用的教程 ,对初学者来说非常有用。

翻译自: https://www.freecodecamp.org/news/how-to-get-started-with-databricks-bc8da4ffbccb/

databricks

databricks_如何开始使用Databricks相关推荐

  1. 中国的“Databricks”们:打造AI基础架构,我们是认真的

    AI落地最大的驱动因素是基础架构的升级. 近年来,大数据分析.AI等领域一直备受关注,常有引人关注的融资事件发生.美国数据科学公司Databricks刚刚在今年8月底完成了16亿美元H轮融资,其最新估 ...

  2. 百亿估值的Databricks,到底是做什么的?

    在Google 中输入"Databricks",看到的前几个建议条目很可能是"IPO"."工作机会"和"估值".这足以表 ...

  3. databricks使用

    1.注册 使用https://community.cloud.databricks.com/login.html注册 2.创建notebook及上传数据 新建notebook,填写名称.语言及集群 上 ...

  4. 【数据分析】Databricks入门:分析COVID-19

    作者 | Renan Ferreira 编译 | VK 来源 | Towards Datas Science 典型的数据科学工作流由以下步骤组成: ❝ 确定业务需求->数据获取->数据准备 ...

  5. 自建Hive数据仓库跨版本迁移到阿里云Databricks数据洞察

    简介:客户在IDC或者公有云环境自建Hadoop集群构建数据仓库和分析系统,购买阿里云Databricks数据洞察集群之后,涉及到数仓数据和元数据的迁移以及Hive版本的订正更新. 直达最佳实践:[自 ...

  6. Databricks:2015 Spark调查报告(部分译文)

    译者:摇摆少年梦 原文地址:https://databricks.com/blog/2015/09/24/spark-survey-results-2015-are-now-available.htm ...

  7. Databricks 企业版 SparkDelta Lake 引擎助力 Lakehouse 高效访问

    简介:本文介绍了Databricks企业版Delta Lake的性能优势,借助这些特性能够大幅提升Spark SQL的查询性能,加快Delta表的查询速度. 作者: 李锦桂(锦犀) 阿里云开源大数据平 ...

  8. 超详攻略!Databricks 数据洞察 - 企业级全托管 Spark 大数据分析平台及案例分析

    简介: 5分钟读懂 Databricks 数据洞察 ~ 更多详细信息可登录 Databricks 数据洞察 产品链接:https://www.aliyun.com/product/bigdata/sp ...

  9. 【实践案例】Databricks 数据洞察在美的暖通与楼宇的应用实践

    简介: 获取更详细的 Databricks 数据洞察相关信息,可至产品详情页查看:https://www.aliyun.com/product/bigdata/spark 作者 美的暖通与楼宇事业部 ...

最新文章

  1. 中国开源正在走向成熟!
  2. 题目1033:继续xxx定律
  3. 百度之星初赛(1)解题报告
  4. POPUP_TO_CONFIRM
  5. webview与js交互
  6. spec文件中的 %pre %post %preun %postun
  7. java kmp算法_KMP算法java版实现
  8. JMeter中持续时间设置成永远调度器才会起作用
  9. c# implicit explicit关键字(隐式和显式数据类型转换)
  10. JAVA内存管理+String创建字符串对象+常量池详解(合集)
  11. 安卓干货——安卓NFC通信
  12. 参考答案+实验设计与分析(第6版) [Design and analysis of experiments] - 蒙哥马利(Montgomery D.C)
  13. 观点| 胡小明:不确定性环境下的智慧城市顶层设计
  14. c语言求圆锥的表面积和体积_有关C语言:求圆锥体的体积和表面积,急!!!!!!1...
  15. 机器学习(线性回归实训)------波士顿房价
  16. 数据库入门理论知识介绍以及编译安装MySql
  17. 惠普linux进入bios设置u盘启动,如何进入bios设置,手把手教你惠普如何进入bios设置u盘启动...
  18. JAVA简单编写幸运抽奖
  19. 判断用户是否使用手机登录
  20. 如何在行中统计满足条件的数据个数占比

热门文章

  1. NodeJS学习笔记(一)——搭建开发框架Express,实现Web网站登录验证
  2. Java Timestamp Memo
  3. web开发中的 emmet 效率提升工具
  4. JavaScript实现自适应宽度的瀑布流
  5. 3.2 读入两个参数
  6. 您有一个上云锦囊尚未领取!
  7. 微信公众号自动回复加超链接最新可用实现方案
  8. SPOJ HIGH Highways ——Matrix-Tree定理 高斯消元
  9. 批处理启动vm虚拟机服务 vm12启动无界面启动vm虚拟机系统 windows上如何操作服务 sc net启动关闭服务...
  10. 1787: [Ahoi2008]Meet 紧急集合