2
Pandasデータフレームから任意の開始インデックスと終了インデックスを使用してデータを取得したいと考えています。たとえば、醜い方法は、このようなものですPandasのインデックスの開始と終了を設定するエレガントな方法
def get_data(self, start=None, end=None):
if start is None and end is not None:
return self.data[:end]
if start is not None and end is None:
return self.data[start:]
if start is not None and end is not None:
return self.data[start:end]
これを行うにはエレガントな方法はありますか?ありがとう!
ご返信ありがとうございます。位置情報の索引作成にも有効です。時間範囲の時系列データの索引付けはどうですか? –
@PengZhao右エンドポイントを挿入しますか? – piRSquared
はい、私は左右両方のエンドポイントが必要です。 –