Skip to content

Commit

Permalink
Merge pull request #83 from DHI/skill-class-set-precision
Browse files Browse the repository at this point in the history
Fix deprecation warning from pandas styler
  • Loading branch information
jsmariegaard authored Sep 28, 2021
2 parents 065591d + 5ed3133 commit 7900296
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fmskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
#
__version__ = "0.4.dev7"
__version__ = "0.3.6"

if "64" not in architecture()[0]:
raise Exception("This library has not been tested for a 32 bit system.")
Expand Down
9 changes: 7 additions & 2 deletions fmskill/skill.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import warnings
from collections.abc import Iterable
import numpy as np
Expand Down Expand Up @@ -170,7 +171,7 @@ def _get_index_level_by_name(self, name):
# raise ValueError(f"name {name} not in index {list(self.index.names)}")

def _id_to_name(self, index, id):
"""Assumes that index is valid and id is int """
"""Assumes that index is valid and id is int"""
if isinstance(id, Iterable):
name_list = []
for i in id:
Expand Down Expand Up @@ -506,7 +507,11 @@ def style(
f"Invalid column name {column} (must be one of {float_cols})"
)

sdf = self.df.style.set_precision(precision)
sdf = (
self.df.style.format(precision=precision)
if sys.version_info >= (3, 7)
else self.df.style.set_precision(precision)
)

# apply background gradient
bg_cols = list(set(columns) & set(float_cols))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="fmskill",
version="0.4.dev7",
version="0.3.6",
install_requires=[
"numpy",
"pandas",
Expand Down

0 comments on commit 7900296

Please sign in to comment.