Planets - Show first and last rows



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

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

df = pd.read_csv(filename)
print(df.head())

print()
print(df.tail(2))

  Planet name  Distance (AU)     Mass
0     Mercury           0.40  0.05500
1       Venus           0.70  0.81500
2       Earth           1.00  1.00000
3        Mars           1.50  0.10700
4       Ceres           2.77  0.00015

   Planet name  Distance (AU)      Mass
9        Pluto           39.0  0.002180
10      Charon           39.0  0.000254