Skip to content

Commit

Permalink
fix: allow timedelta type for period (ydataai#1525)
Browse files Browse the repository at this point in the history
* fix: allow timedelta type for period

* fix(linting): code formatting

---------

Co-authored-by: Azory YData Bot <azory@ydata.ai>
  • Loading branch information
aquemy and azory-ydata authored Jan 8, 2024
1 parent b0c422b commit 4b36db1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/ydata_profiling/model/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Union

from pandas import Timedelta


@dataclass
class BaseAnalysis:
Expand Down Expand Up @@ -55,7 +57,7 @@ class TimeIndexAnalysis:
length: Union[int, List[int]]
start: Any
end: Any
period: Union[float, List[float]]
period: Union[float, List[float], Timedelta, List[Timedelta]]
frequency: Union[Optional[str], List[Optional[str]]]

def __init__(
Expand Down
13 changes: 7 additions & 6 deletions src/ydata_profiling/profile_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import warnings
from pathlib import Path
from typing import Any, Optional, Union

from PIL import Image
import warnings

with warnings.catch_warnings():
warnings.simplefilter("ignore")
import pkg_resources
Expand Down Expand Up @@ -103,11 +104,9 @@ def __init__(
type_schema: optional dict containing pairs of `column name`: `type`
**kwargs: other arguments, for valid arguments, check the default configuration file.
"""


self.__validate_inputs(df, minimal, tsmode, config_file, lazy)



if config_file or minimal:
if not config_file:
config_file = get_config("config_minimal.yaml")
Expand Down Expand Up @@ -352,9 +351,11 @@ def to_file(self, output_file: Union[str, Path], silent: bool = True) -> None:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
pillow_version = pkg_resources.get_distribution("Pillow").version
version_tuple = tuple(map(int, pillow_version.split('.')))
version_tuple = tuple(map(int, pillow_version.split(".")))
if version_tuple < (9, 5, 0):
warnings.warn("Try running command: 'pip install --upgrade Pillow' to avoid ValueError")
warnings.warn(
"Try running command: 'pip install --upgrade Pillow' to avoid ValueError"
)

if not isinstance(output_file, Path):
output_file = Path(str(output_file))
Expand Down

0 comments on commit 4b36db1

Please sign in to comment.