-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13_pandas.py
More file actions
29 lines (21 loc) · 811 Bytes
/
13_pandas.py
File metadata and controls
29 lines (21 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas
if __name__ == '__main__':
# pandas.set_option('display.max_rows', None)
# pandas.set_option('display.max_columns', None)
df = pandas.read_csv("test_data.csv")
print(df)
print("\nDescribe dataframe")
print(df.describe())
df["Total"] = df["Quantity"] * df["PurchasePrice"]
print("\n Dataframe with extra column")
print(df)
df.drop('Total', axis=1, inplace=True)
print("\n Convert column to list")
column = df["LastName"]
print("Values of column ", column.tolist())
print("\n Group by")
# print(df.groupby('City').median(True))
print(df[["FirstName", "City"]].groupby('FirstName').count())
print("\n Sort and filter")
print(df.sort_values(by='PurchasePrice', ascending=False), "\n")
print(df[df['Quantity'] < 15])