import pandas as pd
# always use when .json or using data
df = pd.read_json('files/init.json')
# reading
print(df)
print(df[['Number']])
print()
#try two columns and remove the index from print statement
print(df[['License Plate','Phone Number']].to_string(index=False))
print(df.sort_values(by=['License Plate']))
print()
#sort the values in reverse order
print(df.sort_values(by=['Phone Number'], ascending=False))
print(df[df.Number > 3.00])
print(df[df.Number == df.Number.max()])
print()
print(df[df.Number == df.Number.min()])
import pandas as pd
#the data can be stored as a python dictionary
dict = {
"number": [0,1,2],
"phone": [1234567, 8901234, 1234567]
}
#stores the data in a data frame
print("-------------Dict_to_DF------------------")
df = pd.DataFrame(dict)
print(df)
print("----------Dict_to_DF_labels--------------")
#or with the index argument, you can label rows.
df = pd.DataFrame(dict, index = ["user1", "user2", "user3"])
print(df)
print("-------Examine Selected Rows---------")
#use a list for multiple labels:
print(df.loc[["user1", "user3"]])
#refer to the row index:
print("--------Examine Single Row-----------")
print(df.loc["user1"])
print(df.info())
import pandas as pd
#read csv and sort 'Duration' largest to smallest
df = pd.read_csv('files/initials.csv').sort_values(by=['number'], ascending=False)
print("--Users---------")
print(df.head(10))