First of all, data in Pandas is often contained
in a structure called a dataframe. A dataframe is
a two-dimensional labeled data structure with columns which can
be different types if necessary. For example types like string,
int, float, and Boolean. You can think of a
dataframe as being similar to an Excel spreadsheet. We'll
talk about making dataframes in a bit. For now,
here's what an example dataframe might look like. Using data
describing passengers on the Titanic, and whether or not
they survived the Titanic's tragic collision with an iceberg.
Note that there are numerous columns. Name, age, fare,
and survived? These columns have different data-types. There are also
some Not-a-Number entries which happen when we don't specify
a value. There are a bunch of cool things
we can do with this data frame. Let's jump
to the command line. Say that I had already loaded
this data into a data frame called DF. We can operate on specific
columns by calling on them as if they were keys in a dictionary. For
example, DFH and we can call on specific rows by calling a data frame objects
loc method, and passing the row index as an argument, for example, df.loc('a').
pandasのデータは大抵
データフレームと呼ばれる構造に含まれます
データフレームとは二次元のラベル付きデータ構造で
必要に応じて異なる型になれる列から成ります
文字列型、整数型、浮動小数点数型、ブール型などです
データフレームは
エクセルのスプレッドシートに似ています
データフレームの生成に触れましょう
ここにデータフレームの例があります
タイタニック号の乗客についてと
衝突事故で生き残れたかを記述したデータを使用します
多数の列があることに注目してください
名前、年齢、運賃、生存できたかです
これらの列には異なるデータ型があります
値を指定しない場合に表示される
非数(NaN)の項目もあります
このデータフレームでいろいろなことができます
コマンドラインに入力してみましょう
dfと名付けたデータフレームに
このデータを読み込み済みとします
辞書のキーのように呼び出すことで
特定の列を操作できます
例えば df['age']という具合です
df.loc['a']というようにデータフレームの
オブジェクト locメソッドを使って
引数として行インデックスを渡せば
特定の行を呼び出せます