imsciences 0.6.2.5__py3-none-any.whl → 0.6.2.6__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.
- imsciences/datafunctions.py +9 -3
- {imsciences-0.6.2.5.dist-info → imsciences-0.6.2.6.dist-info}/METADATA +1 -1
- {imsciences-0.6.2.5.dist-info → imsciences-0.6.2.6.dist-info}/RECORD +6 -6
- {imsciences-0.6.2.5.dist-info → imsciences-0.6.2.6.dist-info}/PKG-INFO-IMS-24Ltp-3 +0 -0
- {imsciences-0.6.2.5.dist-info → imsciences-0.6.2.6.dist-info}/WHEEL +0 -0
- {imsciences-0.6.2.5.dist-info → imsciences-0.6.2.6.dist-info}/top_level.txt +0 -0
imsciences/datafunctions.py
CHANGED
|
@@ -109,8 +109,8 @@ class dataprocessing:
|
|
|
109
109
|
|
|
110
110
|
print("\n17. pivot_table")
|
|
111
111
|
print(" - Description: Dynamically pivots a DataFrame based on specified columns.")
|
|
112
|
-
print(" - Usage: pivot_table(df, index_col, columns, values_col, filters_dict=None, fill_value=0,aggfunc='sum',margins=False,margins_name='Total',datetime_trans_needed=True,reverse_header_order = 'False')")
|
|
113
|
-
print(" - Example: pivot_table(df, 'OBS', 'Channel Short Names', 'Value',filters_dict={'Master Include':' == 1','OBS':' >= datetime(2019,9,9)','Metric Short Names':' == 'spd''}, fill_value=0,aggfunc='sum',margins=False,margins_name='Total',datetime_trans_needed=True,reverse_header_order = 'True')")
|
|
112
|
+
print(" - Usage: pivot_table(df, index_col, columns, values_col, filters_dict=None, fill_value=0,aggfunc='sum',margins=False,margins_name='Total',datetime_trans_needed=True,reverse_header_order = 'False',fill_missing_weekly_dates=False,week_commencing='W-MON')")
|
|
113
|
+
print(" - Example: pivot_table(df, 'OBS', 'Channel Short Names', 'Value',filters_dict={'Master Include':' == 1','OBS':' >= datetime(2019,9,9)','Metric Short Names':' == 'spd''}, fill_value=0,aggfunc='sum',margins=False,margins_name='Total',datetime_trans_needed=True,reverse_header_order = 'True',fill_missing_weekly_dates=True,week_commencing='W-MON')")
|
|
114
114
|
|
|
115
115
|
print("\n18. apply_lookup_table_for_columns")
|
|
116
116
|
print(" - Description: Equivalent of xlookup in excel. Allows you to map a dictionary of substrings within a column. If multiple columns are need for the LUT then a | seperator is needed.")
|
|
@@ -664,7 +664,7 @@ class dataprocessing:
|
|
|
664
664
|
|
|
665
665
|
return combined_df
|
|
666
666
|
|
|
667
|
-
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, reverse_header_order=False):
|
|
667
|
+
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, reverse_header_order=False,fill_missing_weekly_dates=False,week_commencing='W-MON'):
|
|
668
668
|
"""
|
|
669
669
|
Provides the ability to create pivot tables, filtering the data to get to data you want and then pivoting on certain columns
|
|
670
670
|
|
|
@@ -680,6 +680,8 @@ class dataprocessing:
|
|
|
680
680
|
margins_name (str, optional): The name of the Totals columns. Defaults to "Total".
|
|
681
681
|
datetime_trans_needed (bool, optional): Whether the index column needs to be transformed into datetime format. Defaults to False.
|
|
682
682
|
reverse_header_order (bool, optional): Reverses the order of the column headers. Defaults to False.
|
|
683
|
+
fill_missing_weekly_dates (bool, optional): Fills in any weekly missing dates. Defaults to False.
|
|
684
|
+
week_commencing (str,optional): Fills in missing weeks if option is specified. Defaults to 'W-MON'.
|
|
683
685
|
|
|
684
686
|
Returns:
|
|
685
687
|
pandas.DataFrame: The pivot table specified
|
|
@@ -730,6 +732,10 @@ class dataprocessing:
|
|
|
730
732
|
# Fill in any NaNs
|
|
731
733
|
pivoted_df = pivoted_df.fillna(fill_value)
|
|
732
734
|
|
|
735
|
+
# If there is a need to fill in missing weeks
|
|
736
|
+
if fill_missing_weekly_dates == True:
|
|
737
|
+
pivoted_df = self.fill_weekly_date_range(pivoted_df, index_col, freq=week_commencing)
|
|
738
|
+
|
|
733
739
|
return pivoted_df
|
|
734
740
|
|
|
735
741
|
def apply_lookup_table_for_columns(self, df, col_names, to_find_dict, if_not_in_dict="Other", new_column_name="Mapping"):
|
|
@@ -3,14 +3,14 @@ dataprocessing/data-processing-functions.py,sha256=vE1vsZ8xOSbR9Bwlp9SWXwEHXQ0nF
|
|
|
3
3
|
dataprocessing/datafunctions.py,sha256=vE1vsZ8xOSbR9Bwlp9SWXwEHXQ0nFydwGkvzHXf2f1Y,41
|
|
4
4
|
imsciences/__init__.py,sha256=GIPbLmWc06sVcOySWwNvMNUr6XGOHqPLryFIWgtpHh8,78
|
|
5
5
|
imsciences/datafunctions-IMS-24Ltp-3.py,sha256=3Snv-0iE_03StmyjtT-riOU9f4v8TaJWLoyZLJp6l8Y,141406
|
|
6
|
-
imsciences/datafunctions.py,sha256=
|
|
6
|
+
imsciences/datafunctions.py,sha256=m5fXoFDJ9bkYMA3tIxsTOr2NmxlWSuoqqi5IvNO2RC8,144041
|
|
7
7
|
imsciences/datapull.py,sha256=TPY0LDgOkcKTBk8OekbD0Grg5x0SomAK2dZ7MuT6X1E,19000
|
|
8
8
|
imsciencesdataprocessing/__init__.py,sha256=quSwsLs6IuLoA5Rzi0ZD40xZaQudwDteF7_ai9JfTPk,32
|
|
9
9
|
imsciencesdataprocessing/datafunctions.py,sha256=vE1vsZ8xOSbR9Bwlp9SWXwEHXQ0nFydwGkvzHXf2f1Y,41
|
|
10
10
|
imsdataprocessing/__init__.py,sha256=quSwsLs6IuLoA5Rzi0ZD40xZaQudwDteF7_ai9JfTPk,32
|
|
11
11
|
imsdataprocessing/datafunctions.py,sha256=vE1vsZ8xOSbR9Bwlp9SWXwEHXQ0nFydwGkvzHXf2f1Y,41
|
|
12
|
-
imsciences-0.6.2.
|
|
13
|
-
imsciences-0.6.2.
|
|
14
|
-
imsciences-0.6.2.
|
|
15
|
-
imsciences-0.6.2.
|
|
16
|
-
imsciences-0.6.2.
|
|
12
|
+
imsciences-0.6.2.6.dist-info/METADATA,sha256=SmZRpsI3cGnW8fQgXurxtsmJgg1GhlotKPOFZ1iPs6o,854
|
|
13
|
+
imsciences-0.6.2.6.dist-info/PKG-INFO-IMS-24Ltp-3,sha256=yqZbigwHjnYoqyI81PGz_AeofRFfOrwH_Vyawyef-mg,854
|
|
14
|
+
imsciences-0.6.2.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
15
|
+
imsciences-0.6.2.6.dist-info/top_level.txt,sha256=hsENS-AlDVRh8tQJ6-426iUQlla9bPcGc0-UlFF0_iU,11
|
|
16
|
+
imsciences-0.6.2.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|