LoginSignup
0
1

More than 1 year has passed since last update.

概要

Seriesの要素を参照する時、番号を指定する方法やインデックス値を指定する方法がある。

インデックス値で参照する場合は、欲しいインデックス値をひとつのリストにまとめてから参照する事ができ、リストではなくひとつの整数値を指定した場合は、その位置に該当するデータのみを取り出す事ができる。

まずはSeriesを生成する

import pandas as pd

fruits = {"banana": 3, "orange": 4, "grape": 1, "peach": 5}
series = pd.Series(fruits)

#いろんなパターンで出力してみる
print(series)

print(series[1])

print(series[[1]])

print(series[0:2])

print(series[:3])

print(series["orange"])

print(series[["orange", "peach"]])

print(series)

image.png

print(series[[1]])

image.png

print(series[0:2])

image.png

print(series[:3])

image.png

print(series["orange"])

image.png

print(series[["orange", "peach"]])

image.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1