Цель: удалить записи из Dataframe на основе столбца 2, index 1, подстроки.

Я пытался:

df = df[df[1] != '305-1']
df = df[df[1] != '305-2']

Однако это абсолютное значение, а не подстрока.

df:

    1   2   3
0   Emissions   305-1~GHG emissions in metric tons of CO2e~Gro...   Emissions for Gross direct (Scope 1) GHG emiss...
1   Emissions   305-3~GHG emissions in metric tons of CO2e~Bio...   Emissions for Biogenic CO2 emissions was 14681...
2   Emissions   305-2~Direct (Scope 1) GHG emissions by gas~CO2 Emissions for CO2 was 107973 tons in year 2014...
3   Emissions   305-2~Direct (Scope 1) GHG emissions by gas~N20 Emissions for N20 was 91661 tons in year 2014,...
4   Emissions   305-3~Direct (Scope 1) GHG emissions by gas~HFCs    Emissions for HFCs was 31744 tons in year 2014...

Желаемый результат df:

1   Emissions   305-3~GHG emissions in metric tons of CO2e~Bio...   Emissions for Biogenic CO2 emissions was 14681...
4   Emissions   305-3~Direct (Scope 1) GHG emissions by gas~HFCs    Emissions for HFCs was 31744 tons in year 2014...

Пожалуйста, дайте мне знать, если я могу еще что-нибудь добавить к публикации.

1
StressedBoi69420 23 Ноя 2021 в 13:14

1 ответ

Лучший ответ