imsciences 0.9.5.2__py3-none-any.whl → 0.9.5.3__py3-none-any.whl

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/mmm.py CHANGED
@@ -492,15 +492,15 @@ class dataprocessing:
492
492
 
493
493
  return combined_df
494
494
 
495
- def pivot_table(self, df, index_col, columns, values_col, filters_dict=None, fill_value=0, aggfunc="sum", margins=False, margins_name="Total", datetime_trans_needed=True, date_format="%Y-%m-%d", reverse_header_order=False, fill_missing_weekly_dates=False, week_commencing="W-MON"):
495
+ def pivot_table(self, df, index_col, columns, values_col, filters_dict=None, fill_value=0, aggfunc="sum", margins=False, margins_name="Total", datetime_trans_needed=True, date_format="%Y-%m-%d", reverse_header_order=False, fill_missing_weekly_dates=True, week_commencing="W-MON"):
496
496
  """
497
497
  Provides the ability to create pivot tables, filtering the data to get to data you want and then pivoting on certain columns
498
498
 
499
499
  Args:
500
500
  df (pandas.DataFrame): The DataFrame containing the data.
501
501
  index_col (str): Name of Column for your pivot table to index on
502
- columns (str): Name of Columns for your pivot table.
503
- values_col (str): Name of Values Columns for your pivot table.
502
+ columns (str or list): Name of Column(s) for your pivot table. Can be a single column or a list of columns.
503
+ values_col (str or list): Name of Values Column(s) for your pivot table. Can be a single column or a list of columns.
504
504
  filters_dict (dict, optional): Dictionary of conditions for the boolean mask i.e. what to filter your df on to get to your chosen cell. Defaults to None
505
505
  fill_value (int, optional): The value to replace nan with. Defaults to 0.
506
506
  aggfunc (str, optional): The method on which to aggregate the values column. Defaults to sum.
@@ -514,14 +514,19 @@ class dataprocessing:
514
514
  Returns:
515
515
  pandas.DataFrame: The pivot table specified
516
516
  """
517
-
518
517
  # Validate inputs
519
518
  if index_col not in df.columns:
520
519
  raise ValueError(f"index_col '{index_col}' not found in DataFrame.")
521
- if columns not in df.columns:
522
- raise ValueError(f"columns '{columns}' not found in DataFrame.")
523
- if values_col not in df.columns:
524
- raise ValueError(f"values_col '{values_col}' not found in DataFrame.")
520
+
521
+ columns = [columns] if isinstance(columns, str) else columns
522
+ for col in columns:
523
+ if col not in df.columns:
524
+ raise ValueError(f"columns '{col}' not found in DataFrame.")
525
+
526
+ values_col = [values_col] if isinstance(values_col, str) else values_col
527
+ for col in values_col:
528
+ if col not in df.columns:
529
+ raise ValueError(f"values_col '{col}' not found in DataFrame.")
525
530
 
526
531
  # Apply filters if provided
527
532
  if filters_dict:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imsciences
3
- Version: 0.9.5.2
3
+ Version: 0.9.5.3
4
4
  Summary: IMS Data Processing Package
5
5
  Author: IMS
6
6
  Author-email: cam@im-sciences.com
@@ -6,7 +6,7 @@ imsciences/datafunctions-IMS-24Ltp-3.py,sha256=3Snv-0iE_03StmyjtT-riOU9f4v8TaJWL
6
6
  imsciences/datafunctions.py,sha256=WZrXNLO-SYrCuFt0pAbha74psMOZPY7meWJ7yWEbRpk,169953
7
7
  imsciences/datapull.py,sha256=TPY0LDgOkcKTBk8OekbD0Grg5x0SomAK2dZ7MuT6X1E,19000
8
8
  imsciences/geo.py,sha256=J8AkLk1Nyty3VBkPFqcseXjtlSvXVNkHW_nymERz3nA,13472
9
- imsciences/mmm.py,sha256=M91Qs_ijtY4EytTo1rruWCOVGnV7DMVaYUhNpP1NVNc,73920
9
+ imsciences/mmm.py,sha256=W7e46fw0c2V9n_-fU3O6F0X1P5tbC2dkMrqnDLJH28g,74230
10
10
  imsciences/pull.py,sha256=bGz8B7bBQ5b9hrx3ipCFTWl_eebEb7rPL4dANKiVWTY,74015
11
11
  imsciences/unittesting.py,sha256=DYGqVCsZHrs_tZ-EXDW8q8CdlcsTnG8HsnmWjEE521c,45691
12
12
  imsciences/vis.py,sha256=2izdHQhmWEReerRqIxhY4Ai10VjL7xoUqyWyZC7-2XI,8931
@@ -14,9 +14,9 @@ imsciencesdataprocessing/__init__.py,sha256=quSwsLs6IuLoA5Rzi0ZD40xZaQudwDteF7_a
14
14
  imsciencesdataprocessing/datafunctions.py,sha256=vE1vsZ8xOSbR9Bwlp9SWXwEHXQ0nFydwGkvzHXf2f1Y,41
15
15
  imsdataprocessing/__init__.py,sha256=quSwsLs6IuLoA5Rzi0ZD40xZaQudwDteF7_ai9JfTPk,32
16
16
  imsdataprocessing/datafunctions.py,sha256=vE1vsZ8xOSbR9Bwlp9SWXwEHXQ0nFydwGkvzHXf2f1Y,41
17
- imsciences-0.9.5.2.dist-info/LICENSE.txt,sha256=lVq2QwcExPX4Kl2DHeEkRrikuItcDB1Pr7yF7FQ8_z8,1108
18
- imsciences-0.9.5.2.dist-info/METADATA,sha256=Zvfy7-y18I-ZFj4aTL18nJOPp57k4uwj5p5ajze5GwI,16994
19
- imsciences-0.9.5.2.dist-info/PKG-INFO-IMS-24Ltp-3,sha256=yqZbigwHjnYoqyI81PGz_AeofRFfOrwH_Vyawyef-mg,854
20
- imsciences-0.9.5.2.dist-info/WHEEL,sha256=ixB2d4u7mugx_bCBycvM9OzZ5yD7NmPXFRtKlORZS2Y,91
21
- imsciences-0.9.5.2.dist-info/top_level.txt,sha256=hsENS-AlDVRh8tQJ6-426iUQlla9bPcGc0-UlFF0_iU,11
22
- imsciences-0.9.5.2.dist-info/RECORD,,
17
+ imsciences-0.9.5.3.dist-info/LICENSE.txt,sha256=lVq2QwcExPX4Kl2DHeEkRrikuItcDB1Pr7yF7FQ8_z8,1108
18
+ imsciences-0.9.5.3.dist-info/METADATA,sha256=J6mScUPG8way2ZfnDauRvqqKDUSriU3dZ1POLQuJmno,16994
19
+ imsciences-0.9.5.3.dist-info/PKG-INFO-IMS-24Ltp-3,sha256=yqZbigwHjnYoqyI81PGz_AeofRFfOrwH_Vyawyef-mg,854
20
+ imsciences-0.9.5.3.dist-info/WHEEL,sha256=ixB2d4u7mugx_bCBycvM9OzZ5yD7NmPXFRtKlORZS2Y,91
21
+ imsciences-0.9.5.3.dist-info/top_level.txt,sha256=hsENS-AlDVRh8tQJ6-426iUQlla9bPcGc0-UlFF0_iU,11
22
+ imsciences-0.9.5.3.dist-info/RECORD,,