Skip to content

Commit

Permalink
CLN: Old helper functions (#22104)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored and jreback committed Jul 29, 2018
1 parent 21cbca6 commit e8e078f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 44 deletions.
7 changes: 0 additions & 7 deletions pandas/core/reshape/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
from pandas.core.dtypes.common import is_list_like

from pandas.compat import reduce
from pandas.core.index import Index
from pandas.core import common as com


def match(needles, haystack):
haystack = Index(haystack)
needles = Index(needles)
return haystack.get_indexer(needles)


def cartesian_product(X):
"""
Numpy version of itertools.product or pandas.compat.product.
Expand Down
23 changes: 1 addition & 22 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import partial
from datetime import datetime, timedelta, time
from datetime import datetime, time
from collections import MutableMapping

import numpy as np
Expand Down Expand Up @@ -850,24 +850,3 @@ def _convert_listlike(arg, format):
return _convert_listlike(arg, format)

return _convert_listlike(np.array([arg]), format)[0]


def format(dt):
"""Returns date in YYYYMMDD format."""
return dt.strftime('%Y%m%d')


OLE_TIME_ZERO = datetime(1899, 12, 30, 0, 0, 0)


def ole2datetime(oledt):
"""function for converting excel date to normal date format"""
val = float(oledt)

# Excel has a bug where it thinks the date 2/29/1900 exists
# we just reject any date before 3/1/1900.
if val < 61:
msg = "Value is outside of acceptable range: {value}".format(value=val)
raise ValueError(msg)

return OLE_TIME_ZERO + timedelta(days=val)
6 changes: 5 additions & 1 deletion pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from pandas import date_range, to_datetime, to_timedelta, Timestamp
import pandas.compat as compat
from pandas.compat import range, lrange, string_types, PY36
from pandas.core.tools.datetimes import format as date_format

import pandas.io.sql as sql
from pandas.io.sql import read_sql_table, read_sql_query
Expand Down Expand Up @@ -2094,6 +2093,11 @@ def test_illegal_names(self):
# -- Old tests from 0.13.1 (before refactor using sqlalchemy)


def date_format(dt):
"""Returns date in YYYYMMDD format."""
return dt.strftime('%Y%m%d')


_formatters = {
datetime: lambda dt: "'%s'" % date_format(dt),
str: lambda x: "'%s'" % x,
Expand Down
14 changes: 0 additions & 14 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
QuarterEnd, BusinessMonthEnd, FY5253,
Nano, Easter, FY5253Quarter,
LastWeekOfMonth, Tick)
from pandas.core.tools.datetimes import format, ole2datetime
import pandas.tseries.offsets as offsets
from pandas.io.pickle import read_pickle
from pandas._libs.tslibs import timezones
Expand All @@ -45,19 +44,6 @@
####


def test_format():
actual = format(datetime(2008, 1, 15))
assert actual == '20080115'


def test_ole2datetime():
actual = ole2datetime(60000)
assert actual == datetime(2064, 4, 8)

with pytest.raises(ValueError):
ole2datetime(60)


def test_to_m8():
valb = datetime(2007, 10, 1)
valu = _to_m8(valb)
Expand Down

0 comments on commit e8e078f

Please sign in to comment.