Skip to content

Commit

Permalink
Updated from_items() function due to pandas deprecation (#228)
Browse files Browse the repository at this point in the history
* updated io/vcf_read.py and stats/misc.py for pandas deprecation. changed all occurences of pandas.DataFrame.from_items(items) to pandas.DataFrame.from_dict(OrderedDict(items))

* add missing import

* release notes [ci skip]
  • Loading branch information
summerela authored and alimanfoo committed Dec 20, 2018
1 parent e038ef6 commit 8642218
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion allel/io/vcf_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import time
import subprocess
import textwrap
from collections import OrderedDict


import numpy as np
Expand Down Expand Up @@ -1771,7 +1772,7 @@ def _chunk_to_dataframe(fields, chunk):
items.append(('%s_%s' % (name, i + 1), a[:, i]))
else:
warnings.warn('cannot handle array %r with >2 dimensions, skipping' % name)
df = pandas.DataFrame.from_items(items)
df = pandas.DataFrame.from_dict(OrderedDict(items))
# treat empty string as missing
df.replace('', np.nan, inplace=True)
return df
Expand Down
6 changes: 3 additions & 3 deletions allel/stats/misc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division
from collections import OrderedDict


import numpy as np
Expand Down Expand Up @@ -244,8 +245,7 @@ def tabulate_state_transitions(x, states, pos=None):
('rpos', switch_positions[:, 1])]

import pandas
return pandas.DataFrame.from_items(items)

return pandas.DataFrame.from_dict(OrderedDict(items))

def tabulate_state_blocks(x, states, pos=None):
"""Construct a dataframe where each row provides information about continuous state blocks.
Expand Down Expand Up @@ -345,4 +345,4 @@ def tabulate_state_blocks(x, states, pos=None):
]

import pandas
return pandas.DataFrame.from_items(items)
return pandas.DataFrame.from_dict(OrderedDict(items))
3 changes: 3 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ v1.2.0 (work in progress)
* Added a convenience function :func:`allel.read_vcf_headers`, to obtain just
header information from a VCF file.

* Fixed pandas deprecation warning (`Summer Rae <https://github.com/summerela>`_,
`#228 <https://github.com/cggh/scikit-allel/pull/228>`_).

* Various documentation improvements (`Peter Ralph
<https://github.com/petrelharp>`_ and `CJ Battey
<https://github.com/cjbattey>`_, `#229
Expand Down

0 comments on commit 8642218

Please sign in to comment.