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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imsciences
3
- Version: 0.9.5
3
+ Version: 0.9.5.1
4
4
  Summary: IMS Data Processing Package
5
5
  Author: IMS
6
6
  Author-email: cam@im-sciences.com
@@ -199,14 +199,14 @@ class geoprocessing:
199
199
 
200
200
  return analysis_df
201
201
 
202
- def process_city_analysis(self, raw_df, spend_df, output_path, group1, group2, response_column):
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
- raw_df (pd.DataFrame): Raw input data containing at least 'date' and 'city' columns, along with the specified response column.
208
- spend_df (pd.DataFrame): DataFrame containing media spend data with 'date', 'geo', and 'cost' columns. Costs should be numeric.
209
- output_path (str): Path to save the final output CSV file.
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.to_csv(output_path, index=False)
273
+ write_file(merged_df, output_path)
249
274
 
250
- return merged_df
275
+ return merged_df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imsciences
3
- Version: 0.9.5
3
+ Version: 0.9.5.1
4
4
  Summary: IMS Data Processing Package
5
5
  Author: IMS
6
6
  Author-email: cam@im-sciences.com
@@ -8,7 +8,7 @@ def read_md(file_name):
8
8
  return f.read()
9
9
  return ''
10
10
 
11
- VERSION = '0.9.5'
11
+ VERSION = '0.9.5.1'
12
12
  DESCRIPTION = 'IMS Data Processing Package'
13
13
  LONG_DESCRIPTION = read_md('README.md')
14
14
 
File without changes
File without changes
File without changes