From 83248478dba380ee32c752eaf317ae62ccdd87fb Mon Sep 17 00:00:00 2001 From: Mikhail Zakharov Date: Tue, 24 Sep 2024 15:58:18 +0200 Subject: [PATCH] tSQLike-1.1.5 --- CHANGELOG.md | 3 ++- tsqlike/tsqlike.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b9e43..a059e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CHANGELOG -* **2024.09.24 Current - tSQLike-1.1.5 (candidate)** +* **2024.09.24 tSQLike-1.1.5** + * `column_map()` respects `use_shortnames`; handles a case with no `function` argument * `group_by()` respects `use_shortnames`; `group_by()` to handle case with no `ftarget` or `function` arguments * `order_by()` respects `use_shortnames` * `join_lt()` respects `use_shortnames` for both Tables diff --git a/tsqlike/tsqlike.py b/tsqlike/tsqlike.py index dbaeaab..1d92bf1 100644 --- a/tsqlike/tsqlike.py +++ b/tsqlike/tsqlike.py @@ -860,7 +860,8 @@ def group_by(self, column='', function=None, ftarget=None, new_tname='', **kwarg """ if not ftarget or not function: - return Table(self) + return Table(name=new_tname if new_tname else + self.name + TNAME_TNAME_DELIMITER + str(self.timestamp), data=self.table) header = self.header if kwargs.get('use_shortnames', self.use_shortnames): @@ -875,16 +876,24 @@ def group_by(self, column='', function=None, ftarget=None, new_tname='', **kwarg data=[[column, ftarget]] + [[k, v] for k, v in gd.items()]) # -------------------------------------------------------------------------------------------- # - def column_map(self, column='', function=None, new_tname=''): + def column_map(self, column='', function=None, new_tname='', **kwargs): """ Apply a function to a column """ + if not function: + return Table(name=new_tname if new_tname else + self.name + TNAME_TNAME_DELIMITER + str(self.timestamp), data=self.table) + + header = self.header + if kwargs.get('use_shortnames', self.use_shortnames): + header = self.make_shortnames() + try: col = -1 if column != '*': - col = self.header.index(column) + col = header.index(column) except ValueError: return Table()