character refine
This commit is contained in:
36
utils.py
36
utils.py
@@ -131,17 +131,21 @@ class JPMCSurvey:
|
||||
|
||||
return df.lazy()
|
||||
|
||||
def _get_subset(self, q: pl.LazyFrame, QIDs, rename_cols=True) -> pl.LazyFrame:
|
||||
def _get_subset(self, q: pl.LazyFrame, QIDs, rename_cols=True, include_record_id=True) -> pl.LazyFrame:
|
||||
"""Extract subset of data based on specific questions."""
|
||||
|
||||
if include_record_id and '_recordId' not in QIDs:
|
||||
QIDs = ['_recordId'] + QIDs
|
||||
|
||||
if not rename_cols:
|
||||
return q.select(QIDs)
|
||||
|
||||
rename_dict = {qid: self.qid_descr_map[qid]['QName'] for qid in QIDs if qid in self.qid_descr_map}
|
||||
rename_dict = {qid: self.qid_descr_map[qid]['QName'] for qid in QIDs if qid in self.qid_descr_map and qid != '_recordId'}
|
||||
|
||||
return q.select(QIDs).rename(rename_dict)
|
||||
|
||||
|
||||
def get_demographics(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_demographics(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the demographics.
|
||||
|
||||
Renames columns using qid_descr_map if provided.
|
||||
@@ -150,7 +154,7 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, QIDs), None
|
||||
|
||||
|
||||
def get_top_8_traits(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_top_8_traits(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the top 8 characteristics are most important for this Chase virtual assistant to have.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -160,7 +164,7 @@ class JPMCSurvey:
|
||||
|
||||
|
||||
|
||||
def get_top_3_traits(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_top_3_traits(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the top 3 characteristics that the Chase virtual assistant should prioritize.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -169,7 +173,7 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, QIDs, rename_cols=False).rename({'QID26_0_GROUP': 'Top_3_Traits'}), None
|
||||
|
||||
|
||||
def get_character_ranking(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_character_ranking(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the ranking of characteristics for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -186,7 +190,7 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, list(QIDs_rename.keys()), rename_cols=False).rename(QIDs_rename), None
|
||||
|
||||
|
||||
def get_18_8_3(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_18_8_3(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the 18-8-3 feedback for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -201,7 +205,7 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, QIDs, rename_cols=False).rename(rename_dict), None
|
||||
|
||||
|
||||
def get_voice_scale_1_10(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_voice_scale_1_10(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the Voice Scale 1-10 ratings for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -218,7 +222,7 @@ class JPMCSurvey:
|
||||
|
||||
|
||||
|
||||
def get_ss_green_blue(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_ss_green_blue(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, dict]:
|
||||
"""Extract columns containing the SS Green/Blue ratings for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -245,7 +249,7 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, list(QIDs_map.keys()), rename_cols=False).rename(QIDs_map), choices_map
|
||||
|
||||
|
||||
def get_top_3_voices(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_top_3_voices(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the top 3 voice choices for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -276,7 +280,7 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, list(QIDs_map.keys()), rename_cols=False).rename(QIDs_map), None
|
||||
|
||||
|
||||
def get_ss_orange_red(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_ss_orange_red(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, dict]:
|
||||
"""Extract columns containing the SS Orange/Red ratings for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
@@ -303,15 +307,11 @@ class JPMCSurvey:
|
||||
return self._get_subset(q, list(QIDs_map.keys()), rename_cols=False).rename(QIDs_map), choices_map
|
||||
|
||||
|
||||
def get_character_refine(self, q: pl.LazyFrame) -> pl.LazyFrame:
|
||||
def get_character_refine(self, q: pl.LazyFrame) -> Union[pl.LazyFrame, None]:
|
||||
"""Extract columns containing the character refine feedback for the Chase virtual assistant.
|
||||
|
||||
Returns subquery that can be chained with other polars queries.
|
||||
"""
|
||||
QIDs = ['QID29', 'QID101', 'QID36_0_GROUP']
|
||||
QIDs = ['QID44', 'QID97', 'QID95', 'QID96']
|
||||
|
||||
rename_dict = {
|
||||
'QID29': '18-8_Set-A',
|
||||
'QID101': '18-8_Set-B',
|
||||
'QID36_0_GROUP': '8-3_Ranked'
|
||||
}
|
||||
return self._get_subset(q, QIDs, rename_cols=True), None
|
||||
Reference in New Issue
Block a user