Skip to Content
スパーク定義ガイド
book

スパーク定義ガイド

by Bill Chambers, Matei Zaharia
March 2025
Intermediate to advanced
606 pages
9h
Japanese
O'Reilly Media, Inc.
Content preview from スパーク定義ガイド

第6章. さまざまな種類のデータを扱う

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

第5章では、基本的なDataFrameの概念と抽象化について説明した。この章( )では、Sparkの構造化演算の基本である演算式の構築について説明する。また、以下のような様々な種類のデータを扱うことについても復習する:

  • ブール

  • 数字

  • 文字列

  • 日付とタイムスタンプ

  • ヌルの取り扱い

  • 複雑なタイプ

  • ユーザ定義関数

APIをどこで探すか

始める前に、ユーザとしてトランスフォームを探すべき場所について説明しておこう。Sparkは成長中のプロジェクトであり、どんな本も(この本も含めて)その時々のスナップショットである。本書の優先事項の1つは、この記述の時点で、データを変換する検索関数の記述場所を教えることである。以下に主な場所を示す:

DataFrame ( ) メソッドDataset

この 、実はちょっとしたトリックがある。というのも、DataFrameはRow 型のデータセットに過ぎないので、実際にはDataset のメソッドを見ることになる。このメソッドはこちらのリンクから入手できる

Dataset のようなサブモジュール DataFrameStatFunctionsそして DataFrameNaFunctionsのようなサブモジュールには、特定の問題セットを解決するメソッドがある。DataFrameStatFunctions例えば、DataFrameNaFunctions がヌルデータを扱うときに関連する関数を指すのに対して、 は統計的に関連するさまざまな関数を保持している。

Column メソッド

これらは第5章で 。これらのメソッドには、aliascontains のような一般化された様々なカラム関連メソッドが含まれている。カラム・メソッドのAPIリファレンスはこちらで発見できる

org.apache.spark.sql.functions には、 、さまざまなデータ型に対するさまざまな関数が含まれている。使用頻度が高いため、パッケージ全体がインポートされていることも多い。 SQL関数とDataFrame関数はここで発見できる

少し圧倒されるかもしれないが、恐れることはない。これらの関数の大部分は、SQLや分析システムで発見されるものだ。これらのツールはすべて、ある形式や構造のデータ行を別の形式に変換するという、ある目的を達成するために存在する。これにより、より多くの行を作成したり、利用可能な行数を減らしたりすることができる。はじめに、この分析に使用するDataFrame を読み取ってみよう:

// in Scala
val df = spark.read.format("csv")
  .option("header", "true")
  .option("inferSchema", "true")
  .load("/data/retail-data/by-day/2010-12-01.csv")
df.printSchema()
df.createOrReplaceTempView("dfTable")
# in Python
df = spark.read.format("csv")\
  .option("header", "true")\
  .option("inferSchema", "true")\
  .load(
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

高性能Spark

高性能Spark

Holden Karau, Rachel Warren
生成AIの可視化

生成AIの可視化

Priyanka Vergadia, Valliappa Lakshmanan
ソフトウェア工学の基礎

ソフトウェア工学の基礎

Nathaniel Schutta, Dan Vega

Publisher Resources

ISBN: 9798341627567