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

fix: allow timedelta type for period #1525

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
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
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
Loading