DataFrame filter rows by size



examples/pandas/planets_filter_rows_by_size.py
import sys
import pandas as pd

filename = "planets.csv"
if len(sys.argv) == 2:
    filename = sys.argv[1]

df = pd.read_csv(filename)


big_ones_selector = df['Mass'] > 1
print(big_ones_selector)
print()

big_ones = df[big_ones_selector]
print(big_ones)

0     False
1     False
2     False
3     False
4     False
5      True
6      True
7      True
8      True
9     False
10    False
Name: Mass, dtype: bool

  Planet name  Distance (AU)   Mass
5     Jupiter            5.2  318.0
6      Saturn            9.5   95.0
7      Uranus           19.6   14.0
8     Neptune           30.0   17.0