-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocessing.py
More file actions
18 lines (17 loc) · 803 Bytes
/
processing.py
File metadata and controls
18 lines (17 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def cast_categories(df):
"""Cast ordered categories to 'cut', 'color', and 'clarity' columns."""
df['cut'] = (df['cut']
.astype('category')
.cat.set_categories(['Fair', 'Good', 'Very Good', 'Ideal',
'Super Ideal'], ordered=True)
)
df['color'] = (df['color']
.astype('category')
.cat.set_categories(['J', 'I', 'H', 'G', 'F', 'E', 'D'],
ordered=True)
)
df['clarity'] = (df['clarity']
.astype('category')
.cat.set_categories(['SI2', 'SI1', 'VS2', 'VS1', 'VVS2',
'VVS1', 'IF', 'FL'], ordered=True)
)