Skip to content

Commit 9d404e8

Browse files
committed
Fix (#28): serialization of indexed Pandas.DataFrames
1 parent 02cb871 commit 9d404e8

File tree

9 files changed

+31
-7
lines changed

9 files changed

+31
-7
lines changed

CHANGELOG.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
------------------------------------------------------------------------------
2+
qPython 1.0.1 [2015.08.11]
3+
------------------------------------------------------------------------------
4+
5+
- Fix: serialization of indexed Pandas.DataFrames
6+
17
------------------------------------------------------------------------------
28
qPython 1.0.0 [2015.04.10]
39
------------------------------------------------------------------------------

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: qpython
3-
version: 1.0.0
3+
version: 1.0.1
44

55
build:
66
number: 1

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __getattr__(cls, name):
6464

6565
# General information about the project.
6666
project = u'qPython'
67-
copyright = u'2014, DEVnet'
67+
copyright = u'2014-2015, DEVnet'
6868

6969
# The version info for the project you're documenting, acts as replacement for
7070
# |version| and |release|, also used in various other places throughout the
@@ -73,7 +73,7 @@ def __getattr__(cls, name):
7373
# The short X.Y version.
7474
version = '1.0'
7575
# The full version, including alpha/beta/rc tags.
76-
release = '1.0-beta'
76+
release = '1.0.1'
7777

7878
# The language for content autogenerated by Sphinx. Refer to documentation
7979
# for a list of supported languages.

qpython/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
__all__ = ['qconnection', 'qtype', 'qtemporal', 'qcollection']
1818

1919

20-
__version__ = '1.0.0'
20+
__version__ = '1.0.1'
21+
22+
try:
23+
from qpython.fastutils import uncompress
24+
except:
25+
__is_cython_enabled__ = False
26+
else:
27+
__is_cython_enabled__ = True
28+
2129

2230
class MetaData(object):
2331
'''Utility class for enriching data structures with meta data, e.g. qtype hint.'''

qpython/_pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _write_pandas_series(self, data, qtype = None):
146146

147147
if qtype is None:
148148
# determinate type based on first element of the numpy array
149-
qtype = Q_TYPE.get(type(data[0]), QGENERAL_LIST)
149+
qtype = Q_TYPE.get(type(data.iloc[0]), QGENERAL_LIST)
150150

151151
if qtype == QSTRING:
152152
# assume we have a generic list of strings -> force representation as symbol list

samples/console.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
# limitations under the License.
1515
#
1616

17+
import qpython
1718
from qpython import qconnection
1819
from qpython.qtype import QException
1920

2021

2122
if __name__ == '__main__':
23+
print('qPython %s Cython extensions enabled: %s' % (qpython.__version__, qpython.__is_cython_enabled__))
2224
with qconnection.QConnection(host = 'localhost', port = 5000) as q:
2325
print(q)
2426
print('IPC version: %s. Is connected: %s' % (q.protocol_version, q.is_connected()))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def read(fname):
3838

3939

4040
setup(name = 'qPython',
41-
version = '1.0.0',
41+
version = '1.0.1',
4242
description = 'kdb+ interfacing library for Python',
4343
long_description=read('README.rst'),
4444

tests/QExpressions3.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ flip `name`iq`misc!(`Dent`Beeblebrox`Prefect;98 42 126;("The Hitch Hiker's Guide
212212
6200630B0002000000706F73006461746573000000020000000B00030000006431006432006433000E00030000006E0100007900000000000080
213213
([eid:1001 1002 1003] pos:`d1`d2`d3;dates:(2001.01.01;2000.05.01;0Nd))
214214
636200630B000100000065696400000001000000070003000000E903000000000000EA03000000000000EB030000000000006200630B0002000000706F73006461746573000000020000000B00030000006431006432006433000E00030000006E0100007900000000000080
215+
([k: 1 2 3] v: `a`b`c)
216+
636200630b00010000006b000000010000000700030000000100000000000000020000000000000003000000000000006200630b000100000076000000010000000b0003000000610062006300
215217
0Ng
216218
fe00000000000000000000000000000000
217219
"G"$"8c680a01-5a49-5aab-5a65-d4bfddb6a661"

tests/pandas_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@
156156
),
157157
'meta': MetaData(**{'qtype': QKEYED_TABLE, 'pos': QSYMBOL_LIST, 'dates': QDATE_LIST, 'eid': QLONG_LIST}),
158158
'index': ['eid'] }),
159+
('([k: 1 2 3] v: `a`b`c)',
160+
{'data': pandas.DataFrame({'k':[1,2,3],'v':['a','b','c']}),
161+
'meta': MetaData(**{'qtype': QKEYED_TABLE}),
162+
'index': ['k'],
163+
'compare_meta': False }),
159164
))
160165

161166

@@ -261,7 +266,8 @@ def test_reading_pandas():
261266
result = result.reset_index()
262267
result.meta = meta
263268

264-
assert value['meta'].as_dict() == result.meta.as_dict(), 'deserialization failed qtype: %s, expected: %s actual: %s' % (query, value['meta'], result.meta)
269+
if not 'compare_meta' in value or value['compare_meta']:
270+
assert value['meta'].as_dict() == result.meta.as_dict(), 'deserialization failed qtype: %s, expected: %s actual: %s' % (query, value['meta'], result.meta)
265271
assert compare(value['data'], result), 'deserialization failed: %s, expected: %s actual: %s' % (query, value['data'], result)
266272
else:
267273
assert compare(value, result), 'deserialization failed: %s, expected: %s actual: %s' % (query, value, result)

0 commit comments

Comments
 (0)