qutePandas 1.0.0__py3-none-any.whl → 1.1.0__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.
@@ -0,0 +1,53 @@
1
+ import pykx as kx
2
+ import pandas as pd
3
+ from ..utils import _ensure_q_table, _handle_return, _validate_columns
4
+
5
+
6
+ def drop_col(df, cols, return_type='q'):
7
+ """
8
+ Removes specified column(s) from the DataFrame.
9
+
10
+ Parameters
11
+ ----------
12
+ df : pandas.DataFrame or pykx.Table
13
+ Input DataFrame.
14
+ cols : list of str or str
15
+ Column names to drop.
16
+ return_type : str, default 'q'
17
+ Desired return type ('p' or 'q').
18
+
19
+ Returns
20
+ -------
21
+ pandas.DataFrame or pykx.Table
22
+ DataFrame with specified column(s) removed.
23
+ """
24
+ try:
25
+ q_table = _ensure_q_table(df)
26
+
27
+ if isinstance(cols, str):
28
+ cols = [cols]
29
+
30
+ if not isinstance(cols, (list, tuple)):
31
+ raise ValueError("cols must be a list of column names")
32
+
33
+ if not cols:
34
+ return _handle_return(q_table, return_type)
35
+
36
+ _validate_columns(q_table, cols)
37
+
38
+ all_cols = kx.q("cols", q_table).py()
39
+ if len(cols) == len(all_cols):
40
+ if return_type == 'p':
41
+ count = kx.q('count', q_table).py()
42
+ return pd.DataFrame(index=range(count))
43
+ else:
44
+ result = kx.q('(0#`)!()')
45
+ return result
46
+ else:
47
+ q_cols = kx.SymbolVector(cols)
48
+ result = kx.q('{[t;c] ![t;();0b;(),c]}', q_table, q_cols)
49
+
50
+ return _handle_return(result, return_type)
51
+
52
+ except Exception as e:
53
+ raise RuntimeError(f"Failed to drop columns {cols}: {e}")
@@ -0,0 +1,35 @@
1
+ import pykx as kx
2
+ import pandas as pd
3
+ from ..utils import _ensure_q_table, _handle_return
4
+
5
+
6
+ def rename(df, columns, return_type='q'):
7
+ """
8
+ Renames columns in the DataFrame.
9
+
10
+ Parameters
11
+ ----------
12
+ df : pandas.DataFrame or pykx.Table
13
+ Input DataFrame.
14
+ columns : dict
15
+ Dictionary mapping old column names to new column names.
16
+ return_type : str, default 'q'
17
+ Desired return type ('p' or 'q').
18
+
19
+ Returns
20
+ -------
21
+ pandas.DataFrame or pykx.Table
22
+ DataFrame with renamed columns.
23
+ """
24
+ try:
25
+ q_table = _ensure_q_table(df)
26
+
27
+ cols = kx.q("cols", q_table).py()
28
+ new_cols = [columns.get(c, c) for c in cols]
29
+ new_cols_str = "`" + "`".join(new_cols)
30
+
31
+ result = kx.q(f'{new_cols_str} xcol', q_table)
32
+ return _handle_return(result, return_type)
33
+ except Exception as e:
34
+ raise RuntimeError(f"Failed to rename columns: {e}")
35
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qutePandas
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A pandas-like library for kdb+/q using pykx
5
5
  Home-page: https://ishapatro.github.io/qutePandas/
6
6
  Author: Isha Patro
@@ -0,0 +1,35 @@
1
+ qutePandas/__init__.py,sha256=BO7UwZvxdpkHzCeXWasLf6mSVx-wOpaBNyXCDlEb_80,2012
2
+ qutePandas/utils.py,sha256=X0GODOBxuAFOtjjFb6IGlzjDhhrkwH_6ErIMypiFhUM,1026
3
+ qutePandas/apply/__init__.py,sha256=tdjeqTQI6jH530lTmpd9dkUPese6B22uI2P4ATKoGzc,92
4
+ qutePandas/apply/apply.py,sha256=OqeNwgoD1G5Y6PK7G_2CX7fswq4_Fl0YDDaqWI7O-a4,2275
5
+ qutePandas/apply/apply_col.py,sha256=h6nAsAXLIC4WcMD-amW3bXkaNEe30SgKEBfUr3eKTng,1597
6
+ qutePandas/cleaning/__init__.py,sha256=6tRzTPgCEumZ7c_TvsMit3pRxZhdzf1Pd4y23ozv_2k,204
7
+ qutePandas/cleaning/dropna.py,sha256=SGIPg8vk4PB1jtnH8hDComuMz8omdraJhOPzKTRiUgI,739
8
+ qutePandas/cleaning/dropna_col.py,sha256=hpR4BN-ZuYdz222aUlYKyrEA7QmYomAMqTK6ebVB0ro,831
9
+ qutePandas/cleaning/fillna.py,sha256=NhYlNpHIlFMMd9ws0dKvw1njxUOmuf6VHLo8oQSUpEA,1057
10
+ qutePandas/cleaning/remove_duplicates.py,sha256=zf6TTbkuSh5S4ZCmgznPLl-erw-umVP7K0EqOyv9wUM,757
11
+ qutePandas/core/__init__.py,sha256=o8WuiBhI5jBqKXTL80kBTNcxZo1aO45dQx2Z6UwWg50,311
12
+ qutePandas/core/connection.py,sha256=CsBWI2jwIO1kNicA42AefmlRgVx5WqayCJPhHzJHhFc,4275
13
+ qutePandas/core/dataframe.py,sha256=bwdm-MVIpoXRo0RblJ_crZVCJlUZgQLN4PmcYu6mdzk,3269
14
+ qutePandas/core/display.py,sha256=ubSZM8yf0kARuiSXpUHJ0WmIt4syjkp-VuV2NAXbiGc,5058
15
+ qutePandas/grouping/__init__.py,sha256=GOBRAWDuh3PnKHEVDzmEqoG_GIfU4G6Gtk0aeSG92lE,116
16
+ qutePandas/grouping/groupby_avg.py,sha256=F8Gc6XdOKiWyNKOoDURgYeeIxIduzbds2mHCfxEtvw4,1129
17
+ qutePandas/grouping/groupby_sum.py,sha256=9XZ2tITeCMRtdnpwH2CpoQh3Y3NDC-ufwiDg6EQUJOA,1128
18
+ qutePandas/indexing/__init__.py,sha256=2MmNlO54FOdIaaPSzegum3QmeO-Ts8ya3xSCodQjTIo,45
19
+ qutePandas/indexing/iloc.py,sha256=g-fG0pxYHn7_qrBwDQ3MRsTi-U_VEtrN4_z5kDNmZaM,2272
20
+ qutePandas/indexing/loc.py,sha256=Xn_043CrKyJBTXhRUYWtU0ZF1yikIGxTI0gTJAYIEfA,1511
21
+ qutePandas/introspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ qutePandas/introspection/dtypes.py,sha256=h3qImsu3JBuELp2zeIfwyOlFTsC513U_qSRNuYzeXWw,705
23
+ qutePandas/io/__init__.py,sha256=sX93I3DAXM_kT0g67Nlhj_tAlVhtQe9Tr4AbgbEle3c,92
24
+ qutePandas/io/from_csv.py,sha256=QQ1lfyXGljvuJ4aL_RRaX7loRgfQ524XvWtBo0fTIHc,671
25
+ qutePandas/io/to_csv.py,sha256=7VrLtEjIUT-gIBXCYhW5GnbiRR2HqAZK6OW8Gy0ZOLM,926
26
+ qutePandas/joining/__init__.py,sha256=INM7LAOy5KqMIUrJdRHt7-no7ODiHsyx4F68hRbddYs,45
27
+ qutePandas/joining/merge.py,sha256=q9-X7QC7omhobO27q2aUego557ewh5RxALzAP7Mgq2M,3854
28
+ qutePandas/transformation/__init__.py,sha256=ECPmFXZq-uh5ajkgAVQbdc8flVzrcwkhEqwiOqqDeag,123
29
+ qutePandas/transformation/cast.py,sha256=VD8D0gPs9GJX52bqu_LKt7BHU69Iv-scOq-E2Q_MGQU,2226
30
+ qutePandas/transformation/drop_col.py,sha256=4hdGjitDbYSfxj-4jo73NmTa2qKed-NjGj0jGBfiANY,1509
31
+ qutePandas/transformation/rename.py,sha256=MwWjbhaZCUdQgkObaMPIB8fUY240x_EdD41cwszCa4o,948
32
+ qutepandas-1.1.0.dist-info/METADATA,sha256=-8cJlJSnucXHNZMShlp5osW2NzdJvg2jcntF-qVsbXE,2540
33
+ qutepandas-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ qutepandas-1.1.0.dist-info/top_level.txt,sha256=O_6KkoxW8KjgZX5o7sYwYVb8XPtNBA7PRSTE08qda1k,11
35
+ qutepandas-1.1.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- qutePandas/__init__.py,sha256=BO7UwZvxdpkHzCeXWasLf6mSVx-wOpaBNyXCDlEb_80,2012
2
- qutePandas/utils.py,sha256=X0GODOBxuAFOtjjFb6IGlzjDhhrkwH_6ErIMypiFhUM,1026
3
- qutepandas-1.0.0.dist-info/METADATA,sha256=x6JQlnuk6MwcDaLy7SkkWu1YcC4TAml13Z4PWRE5l5c,2540
4
- qutepandas-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- qutepandas-1.0.0.dist-info/top_level.txt,sha256=O_6KkoxW8KjgZX5o7sYwYVb8XPtNBA7PRSTE08qda1k,11
6
- qutepandas-1.0.0.dist-info/RECORD,,