前提・実現したいこと
dfの最初の行を消したい
該当のソースコード
このようなdf1があり、一番上の行を消したいです。
In [17]: df1 Out[17]: Lidar Time1 2020-03-17 11:33:57.250 140.0 2020-03-17 11:33:57.300 139.8 2020-03-17 11:33:57.350 139.6 2020-03-17 11:33:57.400 139.4 2020-03-17 11:33:57.450 139.2 2020-03-17 11:33:57.500 139.0 2020-03-17 11:33:57.550 138.8 2020-03-17 11:33:57.600 138.6 2020-03-17 11:33:57.650 138.4 2020-03-17 11:33:57.700 138.2 2020-03-17 11:33:57.750 138.0 2020-03-17 11:33:57.800 138.0 2020-03-17 11:33:57.850 138.0 2020-03-17 11:33:57.900 138.0 2020-03-17 11:33:57.950 138.0 2020-03-17 11:33:58.000 138.0 2020-03-17 11:33:58.050 138.0 2020-03-17 11:33:58.100 138.0 2020-03-17 11:33:58.150 138.0 2020-03-17 11:33:58.200 138.0 2020-03-17 11:33:58.250 138.0 2020-03-17 11:33:58.300 137.6 2020-03-17 11:33:58.350 137.2 2020-03-17 11:33:58.400 136.8 2020-03-17 11:33:58.450 136.4 2020-03-17 11:33:58.500 136.0 2020-03-17 11:33:58.550 135.6 2020-03-17 11:33:58.600 135.2 2020-03-17 11:33:58.650 134.8 2020-03-17 11:33:58.700 134.4 ... ... 2020-03-17 11:42:24.050 144.2 2020-03-17 11:42:24.100 144.4 2020-03-17 11:42:24.150 144.6 2020-03-17 11:42:24.200 144.8 2020-03-17 11:42:24.250 145.0 2020-03-17 11:42:24.300 144.6 2020-03-17 11:42:24.350 144.2 2020-03-17 11:42:24.400 143.8 2020-03-17 11:42:24.450 143.4 2020-03-17 11:42:24.500 143.0 2020-03-17 11:42:24.550 142.8 2020-03-17 11:42:24.600 142.6 2020-03-17 11:42:24.650 142.4 2020-03-17 11:42:24.700 142.2 2020-03-17 11:42:24.750 142.0 2020-03-17 11:42:24.800 142.2 2020-03-17 11:42:24.850 142.4 2020-03-17 11:42:24.900 142.6 2020-03-17 11:42:24.950 142.8 2020-03-17 11:42:25.000 143.0 2020-03-17 11:42:25.050 143.0 2020-03-17 11:42:25.100 143.0 2020-03-17 11:42:25.150 143.0 2020-03-17 11:42:25.200 143.0 2020-03-17 11:42:25.250 143.0 2020-03-17 11:42:25.300 142.8 2020-03-17 11:42:25.350 142.6 2020-03-17 11:42:25.400 142.4 2020-03-17 11:42:25.450 142.2 2020-03-17 11:42:25.500 142.0 [10166 rows x 1 columns]
df1.drop(0) や、
df1.drop("2020-03-17 11:33:57.250") を試しました。
エラーは以下のとおりです。
KeyError
1<ipython-input-18-96e5ef81027c> in <module> 2----> 1 df1.drop(0) 3 4/data/kako/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in drop(self, labels, axis, index, columns, level, inplace, errors) 5 3938 index=index, columns=columns, 6 3939 level=level, inplace=inplace, 7-> 3940 errors=errors) 8 3941 9 3942 @rewrite_axis_style_signature('mapper', [('copy', True), 10 11/data/kako/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in drop(self, labels, axis, index, columns, level, inplace, errors) 12 3778 for axis, labels in axes.items(): 13 3779 if labels is not None: 14-> 3780 obj = obj._drop_axis(labels, axis, level=level, errors=errors) 15 3781 16 3782 if inplace: 17 18/data/kako/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in _drop_axis(self, labels, axis, level, errors) 19 3810 new_axis = axis.drop(labels, level=level, errors=errors) 20 3811 else: 21-> 3812 new_axis = axis.drop(labels, errors=errors) 22 3813 result = self.reindex(**{axis_name: new_axis}) 23 3814 24 25/data/kako/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in drop(self, labels, errors) 26 4963 if errors != 'ignore': 27 4964 raise KeyError( 28-> 4965 '{} not found in axis'.format(labels[mask])) 29 4966 indexer = indexer[~mask] 30 4967 return self.delete(indexer) 31 32KeyError: '[0] not found in axis'
回答2件
あなたの回答
tips
プレビュー