-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed missing timestamp declaration (#30)
* Fixed missing timestamp declaration * Add more test cases
- Loading branch information
1 parent
eeb82af
commit dc8b537
Showing
5 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# flake8: noqa: F841 | ||
|
||
import pandas as pd | ||
import datetime as dt | ||
|
||
def test_types_init() -> None: | ||
ts: pd.Timestamp = pd.Timestamp('2021-03-01T12') | ||
ts1: pd.Timestamp = pd.Timestamp(dt.date(2021, 3, 15)) | ||
ts2: pd.Timestamp = pd.Timestamp(dt.datetime(2021, 3, 10, 12)) | ||
ts3: pd.Timestamp = pd.Timestamp(pd.Timestamp('2021-03-01T12')) | ||
ts4: pd.Timestamp = pd.Timestamp(1515590000.1, unit='s') | ||
ts5: pd.Timestamp = pd.Timestamp(1515590000.1, unit='s', tz='US/Pacific') | ||
ts6: pd.Timestamp = pd.Timestamp(1515590000100000000) # plain integer (nanosecond) | ||
ts7: pd.Timestamp = pd.Timestamp(2021, 3, 10, 12) | ||
ts8: pd.Timestamp = pd.Timestamp(year=2021, month=3, day=10, hour=12) | ||
ts9: pd.Timestamp = pd.Timestamp(year=2021, month=3, day=10, hour=12, tz='US/Pacific') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,85 @@ | ||
from typing import Any | ||
import sys | ||
from typing import Any, Optional, Union, Literal, overload | ||
|
||
from dateutil.tz import tzfile | ||
from datetime import tzinfo, date | ||
|
||
from pandas._libs.tslibs.period import Period | ||
from pandas._typing import DatetimeLikeScalar | ||
|
||
OptInt = Optional[int] | ||
|
||
# Literals have only been introduced in version 3.8 | ||
if sys.version_info >= (3, 8): | ||
Fold = Literal[0, 1] | ||
else: | ||
Fold = int | ||
|
||
class Timestamp: | ||
... | ||
@overload | ||
def __init__(self, ts_input: Union[DatetimeLikeScalar, date, str, int, float], freq: Optional[str] = ..., tz: Optional[Union[str, tzinfo, tzfile]] = ..., unit: Optional[str] = ..., tzinfo: Optional[tzinfo] = ..., fold: Optional[Fold] = ...): ... | ||
@overload | ||
def __init__(self, year: OptInt = ..., month: OptInt = ..., day: OptInt = ..., hour: OptInt = ..., minute: OptInt = ..., second: OptInt = ..., microsecond: OptInt = ..., nanosecond: OptInt = ..., tz: Optional[Union[str, tzinfo, tzfile]] = ..., tzinfo: Optional[tzinfo] = ..., fold: Optional[Fold] = ..., freq: Optional[str] = ...): ... | ||
def to_period(self, freq: Optional[str]) -> Period: ... | ||
def to_julian_date(self) -> float: ... | ||
def tz_localize(self, tz: Any = ..., ambigious: Any = ..., nonexistent: Any = ...) -> Timestamp: ... | ||
def tz_convert(self, tz: Any) -> Timestamp: ... | ||
def astimezone(self, tz: Any) -> Timestamp: ... | ||
def replace(self, year: OptInt = ..., month: OptInt = ..., day: OptInt = ..., hour: OptInt = ..., minute: OptInt = ..., second: OptInt = ..., microsecond: OptInt = ..., nanosecond: OptInt = ..., tzinfo: Optional[tzinfo] = ..., fold: Fold = ...) -> Timestamp: ... | ||
def round(self, freq: str, ambiguous: Any = ..., nonexistent: Any = ...) -> Timestamp: ... | ||
def ceil(self, freq: str, ambiguous: Any = ...,nonexistent: Any = ...) -> Timestamp: ... | ||
def floor(self, freq: str, ambiguous: Any = ...,nonexistent: Any = ...) -> Timestamp: ... | ||
def isoformat(self, sep: str = ...) -> str: ... | ||
def day_name(self, locale: Optional[str]) -> str: ... | ||
def month_name(self, locale: Optional[str]) -> str: ... | ||
def normalize(self) -> Timestamp: ... | ||
|
||
@classmethod | ||
def utcnow(cls) -> Timestamp: ... | ||
@classmethod | ||
def utcfromtimestamp(cls, ts: Timestamp) -> Timestamp: ... | ||
@classmethod | ||
def fromtimestamp(cls, ts: Timestamp) -> Timestamp: ... | ||
@classmethod | ||
def combine(cls, date: Any, time: Any) -> Timestamp: ... | ||
@classmethod | ||
def now(cls, tz: Optional[Any] = ...) -> Timestamp: ... | ||
@classmethod | ||
def today(cls, tz: Optional[Any] = ...) -> Timestamp: ... | ||
@classmethod | ||
def fromordinal(cls, ordinal: Any, freq: Optional[Any] = ..., tz: Optional[Any] = ...) -> Timestamp: ... | ||
@property | ||
def dayofweek(self) -> int: ... | ||
@property | ||
def dayofyear(self) -> int: ... | ||
@property | ||
def quarter(self) -> int: ... | ||
@property | ||
def days_in_month(self) -> int: ... | ||
@property | ||
def daysinmonth(self) -> int: ... | ||
@property | ||
def week(self) -> int: ... | ||
@property | ||
def weekofyear(self) -> int: ... | ||
@property | ||
def freqstr(self) -> str: ... | ||
@property | ||
def is_month_end(self) -> bool: ... | ||
@property | ||
def is_month_start(self) -> bool: ... | ||
@property | ||
def is_quarter_start(self) -> bool: ... | ||
@property | ||
def is_quarter_end(self) -> bool: ... | ||
@property | ||
def is_year_start(self) -> bool: ... | ||
@property | ||
def is_year_end(self) -> bool: ... | ||
@property | ||
def is_leap_year(self) -> bool: ... | ||
@property | ||
def tz(self) -> tzinfo: ... | ||
|
||
|
||
def integer_op_not_supported(obj: Any) -> Any: ... |