-1

How can I delete with the loc function in pandas?

I have a pandas dataframe that has an index. If I select a row with the index like:

testbed.experiment_log.loc[15174159612]

I get the series for that dataframe

type                                   anomaly
event                        stress_disk_nodes
nodes             {10.136.45.96, 10.136.45.95}
date_start                          1517415961
date_end                            1517415981
aditional_info                    Stressors: 6
Name: 1517415961258, dtype: object

How can I delete this row? Please note that I don't want to use the position in the index. Others have pointed out some methods which I have already seen that use df.index, but I want to use the VALUE of the index (same as with df.loc)

Brandon
  • 512
  • 8
  • 26
  • Possible duplicate of [How to drop a list of rows from Pandas dataframe?](https://stackoverflow.com/questions/14661701/how-to-drop-a-list-of-rows-from-pandas-dataframe) – Brad Solomon Jan 31 '18 at 16:55
  • 1
    Actually there are already very good overviews on how to delete based on various conditions: https://chrisalbon.com/python/data_wrangling/pandas_dropping_column_and_rows/ – Gegenwind Jan 31 '18 at 16:58

1 Answers1

0

Actually you don't have to use loc but only the value of the index in that dataframe. In this example:

testbed.experiment_log.drop(1516874441881)
Brandon
  • 512
  • 8
  • 26