take out rows that do not have o3 in python

Assuming you have data in a pandas DataFrame, you can filter rows that contain the string 'o3' in a specific column using the str.contains() method.

Here's an example that filters out all rows where 'o3' is not found in the 'column_name' column:

main.py
import pandas as pd

# read data into a pandas DataFrame
df = pd.read_csv('your_data.csv')

# filter rows that contain 'o3' in the 'column_name' column
df_filtered = df[df['column_name'].str.contains('o3')]
207 chars
8 lines

This will create a new DataFrame df_filtered with only rows where 'o3' is found in the specified column. You can then use this filtered DataFrame for further analysis or export it to a new file with to_csv() method:

main.py
# write filtered data to csv file
df_filtered.to_csv('your_filtered_data.csv', index=False)
92 chars
3 lines

related categories

gistlibby LogSnag