-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample_styles.py
More file actions
65 lines (58 loc) · 1.25 KB
/
sample_styles.py
File metadata and controls
65 lines (58 loc) · 1.25 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# %% [markdown]
"""
# Sample Images
- We would like to sample a twenty images from each of the following categories:
- for `Men` & `Women`
- further categorized by `Topwear`, `Shoes`, `Bottomwear`, `Headwear`
"""
import os
# %%
import pandas as pd
# %%
df = (
pd.read_csv(
os.path.join(
"dataset",
"styles.csv",
),
error_bad_lines=False,
index_col="id",
dtype={
"gender": "category",
"masterCategory": "category",
"subCategory": "category",
"articleType": "category",
"baseColour": "category",
"season": "category",
"productDisplayName": "category",
},
)
.dropna()
.sort_index(
ascending=True,
)
)
df.info()
df.head(3)
# %%
df = df[
df["gender"].isin(["Men", "Women"])
& df["subCategory"].isin(["Topwear", "Shoes", "Bottomwear", "Headwear"])
]
# %%
df = (
df.groupby(["gender", "subCategory"])
.apply(lambda x: x.sample(20, random_state=42))
.sort_index(
ascending=True,
)
)
df.index = df.index.droplevel(["gender", "subCategory"])
# %%
df.to_csv(
os.path.join(
"dataset",
"database",
"ItemCatalogueSample.csv",
)
)