imsciences 0.9.5__tar.gz → 0.9.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of imsciences might be problematic. Click here for more details.
- {imsciences-0.9.5 → imsciences-0.9.5.1}/PKG-INFO +1 -1
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences/geo.py +31 -6
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences.egg-info/PKG-INFO +1 -1
- {imsciences-0.9.5 → imsciences-0.9.5.1}/setup.py +1 -1
- {imsciences-0.9.5 → imsciences-0.9.5.1}/LICENSE.txt +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/README.md +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences/__init__.py +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences/mmm.py +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences/pull.py +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences/unittesting.py +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences/vis.py +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences.egg-info/PKG-INFO-IMS-24Ltp-3 +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences.egg-info/SOURCES.txt +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences.egg-info/dependency_links.txt +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences.egg-info/requires.txt +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/imsciences.egg-info/top_level.txt +0 -0
- {imsciences-0.9.5 → imsciences-0.9.5.1}/setup.cfg +0 -0
|
@@ -199,14 +199,14 @@ class geoprocessing:
|
|
|
199
199
|
|
|
200
200
|
return analysis_df
|
|
201
201
|
|
|
202
|
-
def process_city_analysis(self,
|
|
202
|
+
def process_city_analysis(self, raw_input_path, spend_input_path, output_path, group1, group2, response_column):
|
|
203
203
|
"""
|
|
204
204
|
Process city analysis by grouping data, analyzing user metrics, and merging with spend data.
|
|
205
205
|
|
|
206
206
|
Parameters:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
output_path (str): Path to save the final output CSV
|
|
207
|
+
raw_input_path (str): Path to the raw input data file (CSV or XLSX) containing at least 'date', 'city', and the specified response column.
|
|
208
|
+
spend_input_path (str): Path to the media spend data file (CSV or XLSX) with 'date', 'geo', and 'cost' columns. Costs should be numeric.
|
|
209
|
+
output_path (str): Path to save the final output file (CSV or XLSX).
|
|
210
210
|
group1 (list): List of city regions for group 1.
|
|
211
211
|
group2 (list): List of city regions for group 2.
|
|
212
212
|
response_column (str): Column name to be used as the response metric.
|
|
@@ -215,6 +215,31 @@ class geoprocessing:
|
|
|
215
215
|
pd.DataFrame: Processed DataFrame.
|
|
216
216
|
"""
|
|
217
217
|
import pandas as pd
|
|
218
|
+
import os
|
|
219
|
+
|
|
220
|
+
def read_file(file_path):
|
|
221
|
+
"""Helper function to read CSV or XLSX files."""
|
|
222
|
+
ext = os.path.splitext(file_path)[1].lower()
|
|
223
|
+
if ext == '.csv':
|
|
224
|
+
return pd.read_csv(file_path)
|
|
225
|
+
elif ext in ['.xlsx', '.xls']:
|
|
226
|
+
return pd.read_excel(file_path)
|
|
227
|
+
else:
|
|
228
|
+
raise ValueError("Unsupported file type. Please use a CSV or XLSX file.")
|
|
229
|
+
|
|
230
|
+
def write_file(df, file_path):
|
|
231
|
+
"""Helper function to write DataFrame to CSV or XLSX files."""
|
|
232
|
+
ext = os.path.splitext(file_path)[1].lower()
|
|
233
|
+
if ext == '.csv':
|
|
234
|
+
df.to_csv(file_path, index=False)
|
|
235
|
+
elif ext in ['.xlsx', '.xls']:
|
|
236
|
+
df.to_excel(file_path, index=False, engine='openpyxl')
|
|
237
|
+
else:
|
|
238
|
+
raise ValueError("Unsupported file type. Please use a CSV or XLSX file.")
|
|
239
|
+
|
|
240
|
+
# Read input files
|
|
241
|
+
raw_df = read_file(raw_input_path)
|
|
242
|
+
spend_df = read_file(spend_input_path)
|
|
218
243
|
|
|
219
244
|
# Ensure necessary columns are present
|
|
220
245
|
required_columns = {'date', 'city', response_column}
|
|
@@ -245,6 +270,6 @@ class geoprocessing:
|
|
|
245
270
|
merged_df['cost'] = merged_df['cost'].fillna(0)
|
|
246
271
|
|
|
247
272
|
# Save the final output
|
|
248
|
-
merged_df
|
|
273
|
+
write_file(merged_df, output_path)
|
|
249
274
|
|
|
250
|
-
return merged_df
|
|
275
|
+
return merged_df
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|