0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

df[[]] と df[]の違い

Last updated at Posted at 2024-02-21

列の場合

df[["Adj Close"]]    # データフレーム

df["Adj Close"]      # シリーズ

df[]とdf[[]]の違い2.png
df[]とdf[[]]の違い1.png

行の場合

df.loc[["Sato"]]     # データフレーム

df.loc["Sato"]       # シリーズ

スクリーンショット 2024-07-15 16.50.11.jpeg

おまけ

df.loc['Sato','height']
# 結果
180

重要なのは、df.loc[]の括弧の中は
先に、indexの要素
後に、columnsの要素

逆だと、エラーになるようだ。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?