Spaces:
Sleeping
Sleeping
Update helper.py
Browse files
helper.py
CHANGED
@@ -14,6 +14,27 @@ def assign_main_accounts(creators_file, chatter_files):
|
|
14 |
creators = pd.read_excel(creators_file)
|
15 |
creators.columns = creators.columns.str.strip()
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
creators["Total earnings"] = creators["Total earnings"].replace("[\$,]", "", regex=True).astype(float)
|
18 |
creators["Subscription"] = creators["Subscription"].replace("[\$,]", "", regex=True).astype(float)
|
19 |
creators["ActiveFans"] = pd.to_numeric(creators["ActiveFans"], errors="coerce").fillna(0)
|
@@ -51,7 +72,6 @@ def assign_main_accounts(creators_file, chatter_files):
|
|
51 |
|
52 |
|
53 |
|
54 |
-
|
55 |
def save_processed_files(assignments, output_dir):
|
56 |
"""
|
57 |
Save processed files for main assignments, ensuring chatter names and main accounts are preserved correctly.
|
|
|
14 |
creators = pd.read_excel(creators_file)
|
15 |
creators.columns = creators.columns.str.strip()
|
16 |
|
17 |
+
# Debugging: Check initial columns
|
18 |
+
print("DEBUG: Initial Columns in Creator File:", creators.columns)
|
19 |
+
|
20 |
+
column_mapping = {
|
21 |
+
"Creator": "Creator",
|
22 |
+
"Total earnings": "Total earnings",
|
23 |
+
"Subscription": "Subscription",
|
24 |
+
"Active Fans": "ActiveFans",
|
25 |
+
"Total active fans": "ActiveFans",
|
26 |
+
}
|
27 |
+
creators.rename(columns={k: v for k, v in column_mapping.items() if k in creators.columns}, inplace=True)
|
28 |
+
|
29 |
+
# Debugging: Check renamed columns
|
30 |
+
print("DEBUG: Renamed Columns in Creator File:", creators.columns)
|
31 |
+
|
32 |
+
required_columns = ["Creator", "Total earnings", "Subscription", "ActiveFans"]
|
33 |
+
missing_columns = [col for col in required_columns if col not in creators.columns]
|
34 |
+
if missing_columns:
|
35 |
+
raise KeyError(f"Missing required columns in creators file: {missing_columns}")
|
36 |
+
|
37 |
+
# Process creators file
|
38 |
creators["Total earnings"] = creators["Total earnings"].replace("[\$,]", "", regex=True).astype(float)
|
39 |
creators["Subscription"] = creators["Subscription"].replace("[\$,]", "", regex=True).astype(float)
|
40 |
creators["ActiveFans"] = pd.to_numeric(creators["ActiveFans"], errors="coerce").fillna(0)
|
|
|
72 |
|
73 |
|
74 |
|
|
|
75 |
def save_processed_files(assignments, output_dir):
|
76 |
"""
|
77 |
Save processed files for main assignments, ensuring chatter names and main accounts are preserved correctly.
|