Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated pandas Series.as_matrix() with Series.values() #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions qpython/_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def _read_dictionary(self, qtype = QDICTIONARY):

return table
else:
keys = keys if not isinstance(keys, pandas.Series) else keys.as_matrix()
values = values if not isinstance(values, pandas.Series) else values.as_matrix()
keys = keys if not isinstance(keys, pandas.Series) else keys.values()
values = values if not isinstance(values, pandas.Series) else values.values()
return QDictionary(keys, values)
else:
return QReader._read_dictionary(self, qtype = qtype)
Expand Down Expand Up @@ -168,19 +168,19 @@ def _write_pandas_series(self, data, qtype = None):
raise QWriterException('Unable to serialize pandas series %s' % data)

if qtype == QGENERAL_LIST:
self._write_generic_list(data.as_matrix())
self._write_generic_list(data.values())
elif qtype == QCHAR:
self._write_string(data.replace(numpy.nan, ' ').as_matrix().astype(numpy.string_).tostring())
self._write_string(data.replace(numpy.nan, ' ').values().astype(numpy.string_).tostring())
elif data.dtype.type not in (numpy.datetime64, numpy.timedelta64):
data = data.fillna(QNULLMAP[-abs(qtype)][1])
data = data.as_matrix()
data = data.values()

if PY_TYPE[qtype] != data.dtype:
data = data.astype(PY_TYPE[qtype])

self._write_list(data, qtype = qtype)
else:
data = data.as_matrix()
data = data.values()
data = data.astype(TEMPORAL_Q_TYPE[qtype])
self._write_list(data, qtype = qtype)

Expand Down