2020-06-08から1日間の記事一覧

Python DataFrameを作成するその④

続いてはDataFrameの限定した値を取得します df_loc_rowcol = df.loc['second', 'C'] print(df_loc_rowcol) 結果 "g" df_loc_rowcol = df.loc[['second', 'fourth'], ['A', 'D']]print(df_loc_rowcol) 結果 A D second e h fourth m p ☆ポイント☆ DataFrame.…

Python DataFrameを作成するその③

続いて行の値を取り出します。 df = pd.DataFrame([list('abcd'), list('efgh'), list('ijkl'), list('mnop')], index=['first', 'second', 'third', 'fourth'], columns=list('ABCD')) A B C D first a b c d second e f g h third i j k l fourth m n o p …

Python DataFrameを作成するその②

続いてはDataFrameの中の任意の場所だけ抜き出します。 A B C D 0 a b c d 1 e f g h df_bd = df'B', 'D' print(df_bd) B D 0 b d 1 f h ※列がちょっとずれてます df_b = df'B'print(df_b) B 0 b 1 f 以上、ちゃあ少佐でした。

Python DataFrameを作成するその①

続いてDataFrameを作成します。 import pandas as pd df = pd.DataFrame([list('abcd'), list('efgh')])print(df) df_values = df.valuesprint(df_values) df_columns = df.columnsprint(df_columns) df_index = df.indexprint(df_index) 結果 0 1 2 3 0 a b…

Python Seriesについて

こんにちは。ちゃあ少佐です。 Python 学習20日目 今日はSeriesについて勉強しますです。 表の中から一列分だけ抜き出したものをSeriesというらしい。 import pandas as pd sample_list = ['a', 'b', 'c', 'd']series = pd.Series(sample_list) print(series…