import pandas as pd import numpy as np n = ["Jake", "Annie", "Charles", "Sam", "David"] g = [80, 90, 75, 64, 78] # create a data frame df = pd.DataFrame() df["name"], df["grade"] = n, g print(df, "\n") # sort by name df.sort_values(by=["name"], ascending=[True], inplace=True) print(df, "\n") # reset index df.reset_index(inplace=True, drop=True) print(df, "\n")
No comments:
Post a Comment