02Excelから入るデータ整備 / Data Preparation with Excel

【目次/TOC】

  1. 構造化データのイメージづくり
    Concept of Structured Data
  2. Excelにおけるデータ入力と計算機としての使い方
    Data Entry in Excel and Using Excel as a Calculator
  3. 値の型と表現形式
    Types of Value and Formats
  4. Excelにおけるデータ操作
    Data Manipulation in Excel
  5. データクレンジングとデータラングリング
    Data Cleansing and Data Wrangling
Last Modified 2024.6.20

1. 構造化データのイメージづくり/Concept of Structured Data

このページは『超入門・はじめてのAI・データサイエンス』(培風館)の第2章に対応しています。構造化データとは,行と列からなるデータのことです。構造化データ以外のすべてのデータは,非構造化データです。非構造化データには,画像,音声,文字,映像など様々なものがあります。Excelから構造化データに慣れていきましょう。

This page corresponds to Session 02. Structured data is data consisting of rows and columns. All data other than structured data is unstructured data. Unstructured data includes various types of data such as images, sound, text and video. Let's get used to structured data by starting with Excel.

2. Excelにおけるデータ入力と計算機としての使い方
Data Entry in Excel and Using Excel as a Calculator

Excelの1つのファイルをワークブックといいます。ワークブックは, ページのようにみえるワークシートから構成されています。 シート見出しをクリックして,他のワークシートを選択したり,シート見出しにあるプラス印をクリックして新しいワークシートを追加したり,シート見出しを右クリックしてワークシートを 削除したり, コピーしたりすることができます。シート見出しをドラッグして,ワークシートの位置を移動することができます。

A single Excel file is called a workbook. A workbook consists of worksheets that look like pages. To select another worksheet, click on a sheet tab. To insert a new worksheet, click on the sheet tab with a plus sign. To delete or copy a worksheet, right-click on a sheet tab and select from the options. You can also use the ribbon to insert or delete a worksheet. You can move a worksheet by dragging the sheet tab.

入力は,セルに直接か,数式バーに内容を打ち込み,WindowsはEnterキー,MacはReturnキーで入力します。 Microsoft Excelの使い方は,Microsoft社が ビデオトレーニングを用意しているので,必要に応じて参照してください。 『超入門・はじめてのAI・データサイエンス』2.2 の四則演算以外の数式の記号は,Microsoft社の こちらを見てください。

Input is done either by typing directly into the cell or by typing into the formula bar, and then hitting the Enter key for Windows or the Return key for Mac. Microsoft provides video training on how to use Microsoft Excel, so please refer to it if you like. If you want to know formula symbols, see here.

3. 値の型と表現形式/Types of Value and Formats

セルは結合しないこと,数値データは数値で入力すべきことなど,総務省が公表した統計表における機械判読可能なデータの表記方法の統一ルールはこちらです。

For the rules for machine-readable data the Ministry of Internal Affairs and Communications (MIC) has formulated, please see its website in Japanese. To list a few, the rule says, "Don’t merge cells.” or "To use formula, numbers should be in numerical formats".

2. Excelにおけるデータ操作/Data Manipulation in Excel

2.4.1 列の挿入,フィルハンドルを使ったオートフィル/Insert Columns, Auto-Fill with Fill Handles

下の動画では,Excelにおけるワークシートのコピーと移動,エラーインジケータ,列の挿入セル内の文字配置太字フィルハンドルを使ったオートフィルファイルの保存について紹介しています。




セル範囲の選択とコピー,移動/Select, Copy or Move Cell Contents

下の動画では,Excelにおけるセル範囲の選択列の幅の調整形式を選択して貼り付けを紹介しています。

The video below shows how to select cell contents, adjust column widths, and paste options in Excel.






2.4.3 検索と置換/Find and Replace

2.4.4 相対参照,絶対参照,複合参照/Relative, Absolute, and Mixed References

2.4.5 罫線とセルの結合/Combining Ruled Lines and Cells

「検索と置換」の動画では,検索と置換,セル内改行,セルの参照#DIV/0!罫線セルの結合書式の貼り付けを紹介しています。

The video "Find and Replace" touches on Find and Replace, line feed within a cell, cell reference, #DIV/0!cell borderscell merge,and format painter.






2.4.6 関数(NOW, TEXT, IF)/Functions (NOW, TEXT, IF)

2.4.7 リドゥとリピート/Redo and Repeat

下の「関数(NOW, TEXT, IF)」には,Excelの日付関数IF関数リドゥとリピートが含まれています。コピーできるコードも下記に埋め込んでいます。

The video "Functions (NOW, TEXT, IF)" below includes Excel's date functions, IF functions, redo and repeat. Code that can be copied is also embedded below.

下記は書籍p.20の1つ目のExcel関数です。曜日をとりだした文字列のセルがC6であることを想定しています。

The following is the first Excel function on p.20 of the book. It is assumed that the text for the day of the week is in C6.


=IF(C6="Sat","ビン・缶","なし)

=IF(C6="Sat","Glass bottles and metal cans","None")

下記は書籍p.20の2つ目のExcel関数です。

The following is the second Excel function on p.20 of the book.


=IF(C6="Sat","ビン・缶",IF(C6="Mon","可燃ごみ","なし"))

=IF(C6="Sat","Glass bottles and metal cans",IF(C6="Mon","Combustibles","None"))

IF 関数はさらに入れ子にしていくことができます。1 つ目の IF(あてはまれば, これを表示, それ以外の場合,2 つ目の IF(あてはまれば, これを表示, それ以外はこれ))... と 3 つ 目,4 つ目... と IF 式を入れ子にして条件を重ねていくことができます。

IF functions can be nested further. The first IF (if applicable, show this, otherwise, the second IF (if applicable, show this, otherwise this))... and the third, fourth, and so on. The conditions can be nested in a series of IF expressions.


=IF(C6="Mon","可燃ごみ",IF(E4="Wed","不燃ごみ",IF(E4="Thu","可燃ごみ",IF(E4="Sat","ビン・缶",IF(E4="Sun","古紙","なし")))))

=IF(C6="Mon","Combustibles",IF(E4="Wed","Noncombustibles",IF(E4="Thu","Combustible",IF(E4="Sat","Glass bottles and metal cans",IF(E4="Sun","Papers","None")))))



2.4.8 フラッシュフィル,SUM, SUMIF, 並べ替え/Flash Fill, SUM, SUMIF, Sort

「フラッシュフィル,SUM, SUMIF, SORT」という動画では,ExcelのフラッシュフィルSUM関数, SUMIF関数, 並べ替えを紹介しています。

The video "Flash Fill, SUM, SUMIF, SORT" introduces Excel's Flash Fill, SUM function, SUMIF function, and Sort.




2.4.9 名前の定義/Defined Names

このセクションの動画は,名前の定義についてです。

The video in this section is about defined names.

動画は順次アップデート予定です/Videos will be updated soon.




2.4.10 入力規則プルダウン/Drop-Down List in Data Validation

データの入力規則からプルダウンリストを挿入する方法です。

About how to insert a Drop-down list from Data Validation.




3. データクレンジングとデータラングリング/Data Cleansing and Data Wrangling

2.5.4 文字コード/Character Encoding

ここでいう文字コードとは,バイト表現と文字の対応関係の体系のことです。 ファイルを読み込んだ時に文字化けをしてしまう場合の原因は多くの場合,文字コードの違いです。 ここではその対処法について紹介します。

A character code refers to a system of correspondence between byte representations and characters. In many cases, the cause of garbled characters when a file is read is a difference in character encoding. In this section is about how to deal with this problem.

動画の1つ目は,csvファイルをテキストファイルとして開いて,エンコードをANSIにして保存し直す方法を紹介しています。 Excelに限らず,文字化け問題に対処する一般的な方法で,将来どのようなOS,どのようなツールを使うことになっても,覚えておいて損のない知識です。

The first video shows how to open a csv file as a text file and re-save it with ANSI encoding. This is a basic method to deal with garbled text problems, not only in Excel, and is good knowledge to have no matter what kind of OS or tools you will be using in the future.




動画の2つ目は,リボンの「データ」の中にある「テキストまたはcsvから」を使って文字化けなしにcsvファイルを読み込む方法です。 パワークエリに接続して読み込む方法ですが,パワークエリについては簡単にですがまた改めて紹介するので,今回はこのような文字化けに対する対処法もあるというにとどめます。

The second video shows how to read a csv file without garbled characters using "From Text/CSV" in the "Data" ribbon. This is a method that connects the data to a Power Query to read the file. Since I will introduce Power Query in a later session, I will only mention that there is a way to deal with such garbled characters.




2.5.5 文字列操作関数を使った実習/Text Functions (Practice)

文字列(操作)関数を使ってデータクレンジングをしていく方法です。

This section is about how to do data cleansing with Text Functions.




2.5.6 フィルタ,データの入力規則,重複する値/Filter, Data Validation, Finding Duplicates

最後に,文字列関数以外でデータクレンジングをしていくいくつかの方法についてです。

The final video of this session introduces some other ways to do data cleansing in Excel.