Skip to content

Commit

Permalink
Make pandas optional
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Feb 2, 2024
1 parent 94e2cb2 commit d76cdfd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install project
run: |
python -m pip install --upgrade pip
pip install '.[dev,examples]'
pip install '.[dev,examples,pandas]'
- name: Test
run: pytest
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

- Make pandas optional ([#43](https://github.com/gadomski/pyisd/pull/43))

## [0.3.0] - 2024-02-02

### Added
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ classifiers = [
"Operating System :: OS Independent",
]
requires-python = ">=3.9"
dependencies = ["click~=8.0", "pandas~=1.3"]
dependencies = ["click~=8.0"]

[project.scripts]
isd = "isd.cli:main"
Expand All @@ -20,6 +20,7 @@ isd = "isd.cli:main"
dev = ["mypy~=1.2", "pre-commit~=3.2", "pytest~=8.0", "ruff~=0.1.9"]
examples = ["tqdm~=4.66"]
docs = ["sphinx~=7.2"]
pandas = ["pandas~=1.3"]

[build-system]
requires = ["setuptools>=45", "wheel"]
Expand Down
9 changes: 6 additions & 3 deletions src/isd/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from io import BytesIO
from pathlib import Path
from dataclasses import dataclass
from typing import List, Union, Optional, Dict, Any, Iterator
from typing import List, Union, Optional, Dict, Any, Iterator, TYPE_CHECKING
import datetime

from isd.record import Record

import pandas
if TYPE_CHECKING:
import pandas


@dataclass
Expand Down Expand Up @@ -81,6 +82,8 @@ def to_json(self, indent: int = 4) -> str:
data.append(d)
return json.dumps(data, indent=indent)

def to_data_frame(self) -> pandas.DataFrame:
def to_data_frame(self) -> "pandas.DataFrame":
"""Reads a local ISD file into a DataFrame."""
import pandas

return pandas.DataFrame([record.to_dict() for record in self.records])

0 comments on commit d76cdfd

Please sign in to comment.