Skip to content

Commit 7a50408

Browse files
committed
pandas.index -> pandas.libs.index
1 parent 303e452 commit 7a50408

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+105
-98
lines changed

doc/source/whatsnew/v0.20.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ If indicated, a deprecation warning will be issued if you reference that module.
466466
"pandas._sparse", "pandas.sparse.libsparse", ""
467467
"pandas._hash", "pandas.tools.libhash", ""
468468
"pandas.tslib", "pandas.libs.tslib", ""
469+
"pandas.index", "pandas.libs.index", ""
469470

470471

471472
.. _whatsnew_0200.api_breaking.groupby_describe:

pandas/compat/pickle_compat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def load_reduce(self):
6565

6666
# 12588, extensions moving
6767
('pandas._sparse', 'BlockIndex'): ('pandas.sparse.libsparse', 'BlockIndex')
68+
('pandas.tslib', 'Timestamp'): ('pandas.libs.tslib', 'Timestamp'),
69+
('pandas.tslib', '__nat_unpickle'): ('pandas.libs.tslib', '__nat_unpickle')
6870
}
6971

7072

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from warnings import warn
77
import numpy as np
88

9-
from pandas import compat, lib, tslib, _np_version_under1p8
9+
from pandas import compat, lib, _np_version_under1p8
1010
from pandas.types.cast import _maybe_promote
1111
from pandas.types.generic import ABCSeries, ABCIndex
1212
from pandas.types.common import (is_unsigned_integer_dtype,
@@ -1411,7 +1411,7 @@ def diff(arr, n, axis=0):
14111411
if needs_i8_conversion(arr):
14121412
dtype = np.float64
14131413
arr = arr.view('i8')
1414-
na = tslib.iNaT
1414+
na = iNaT
14151415
is_timedelta = True
14161416
elif issubclass(dtype.type, np.integer):
14171417
dtype = np.float64

pandas/core/nanops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
except ImportError: # pragma: no cover
1010
_USE_BOTTLENECK = False
1111

12-
from pandas import compat, lib, algos, tslib
12+
from pandas import compat, lib, algos
13+
from pandas.libs import tslib
1314
from pandas.types.common import (_get_dtype,
1415
is_float, is_scalar,
1516
is_integer, is_complex, is_float_dtype,

pandas/core/ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import numpy as np
1111
import pandas as pd
1212
import datetime
13-
from pandas import compat, lib, tslib
14-
import pandas.index as _index
13+
from pandas import compat, lib
1514
from pandas.util.decorators import Appender
1615
import pandas.computation.expressions as expressions
1716
from pandas.lib import isscalar
17+
from pandas.libs import index as _index, tslib
1818
from pandas.libs.tslib import iNaT
1919
from pandas.compat import bind_method
2020
import pandas.core.missing as missing

pandas/core/series.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
from pandas.util.validators import validate_bool_kwarg
7070

7171
import pandas.lib as lib
72-
import pandas.libs.tslib as tslib
73-
import pandas.index as _index
72+
from pandas.libs import index as _index, tslib
73+
from pandas.libs.tslib import iNaT
7474

7575
from pandas.core.config import get_option
7676

@@ -733,7 +733,7 @@ def setitem(key, value):
733733
elif is_timedelta64_dtype(self.dtype):
734734
# reassign a null value to iNaT
735735
if isnull(value):
736-
value = tslib.iNaT
736+
value = iNaT
737737

738738
try:
739739
self.index._engine.set_value(self._values, key,

pandas/indexes/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import operator
44

55
import numpy as np
6-
import pandas.libs.tslib as tslib
6+
from pandas.libs import index as _index, tslib
77
import pandas.lib as lib
88
import pandas._join as _join
99
import pandas.algos as _algos
10-
import pandas.index as _index
1110
from pandas.lib import Timestamp, Timedelta, is_datetime_array
1211

1312
from pandas.compat import range, u

pandas/indexes/category.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
import pandas.index as _index
2+
import pandas.libs.index as _index
33

44
from pandas import compat
55
from pandas.compat.numpy import function as nv

pandas/indexes/multi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import numpy as np
99
import pandas.lib as lib
10-
import pandas.index as _index
10+
import pandas.libs.index as _index
1111
from pandas.lib import Timestamp
1212

1313
from pandas.compat import range, zip, lrange, lzip, map

pandas/indexes/numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pandas.lib as lib
33
import pandas._join as _join
44
import pandas.algos as _algos
5-
import pandas.index as _index
5+
from pandas.libs import index as _index
66

77
from pandas.types.common import (is_dtype_equal, pandas_dtype,
88
is_float_dtype, is_object_dtype,

pandas/indexes/range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import operator
33

44
import numpy as np
5-
import pandas.index as _index
5+
import pandas.libs.index as _index
66

77
from pandas.types.common import (is_integer,
88
is_scalar,

pandas/index.pyx renamed to pandas/libs/index.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ cimport util
1515

1616
import numpy as np
1717

18-
cimport libs.tslib
19-
from hashtable cimport *
18+
cimport tslib
19+
from ..hashtable cimport *
2020
from pandas import algos, hashtable as _hash
2121
from pandas.libs import tslib
2222
from pandas.libs.tslib import Timestamp, Timedelta

pandas/sparse/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pandas.core import generic
2121
import pandas.core.common as com
2222
import pandas.core.ops as ops
23-
import pandas.index as _index
23+
import pandas.libs.index as _index
2424
from pandas.util.decorators import Appender
2525

2626
from pandas.sparse.array import (make_sparse, _sparse_array_op, SparseArray,

pandas/src/inference.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from decimal import Decimal
33
cimport util
4-
from tslib import NaT, get_timezone
4+
from libs.tslib import NaT, get_timezone
55
from datetime import datetime, timedelta
66
iNaT = util.get_nat()
77

pandas/src/period.pyx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def extract_ordinals(ndarray[object] values, freq):
474474
p = values[i]
475475

476476
if is_null_datetimelike(p):
477-
ordinals[i] = tslib.iNaT
477+
ordinals[i] = iNaT
478478
else:
479479
try:
480480
ordinals[i] = p.ordinal
@@ -485,9 +485,9 @@ def extract_ordinals(ndarray[object] values, freq):
485485

486486
except AttributeError:
487487
p = Period(p, freq=freq)
488-
if p is tslib.NaT:
488+
if p is NaT:
489489
# input may contain NaT-like string
490-
ordinals[i] = tslib.iNaT
490+
ordinals[i] = iNaT
491491
else:
492492
ordinals[i] = p.ordinal
493493

@@ -716,8 +716,8 @@ cdef class _Period(object):
716716
"""
717717
Fast creation from an ordinal and freq that are already validated!
718718
"""
719-
if ordinal == tslib.iNaT:
720-
return tslib.NaT
719+
if ordinal == iNaT:
720+
return NaT
721721
else:
722722
self = _Period.__new__(cls)
723723
self.ordinal = ordinal
@@ -730,7 +730,7 @@ cdef class _Period(object):
730730
msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
731731
raise IncompatibleFrequency(msg)
732732
return PyObject_RichCompareBool(self.ordinal, other.ordinal, op)
733-
elif other is tslib.NaT:
733+
elif other is NaT:
734734
return _nat_scalar_rules[op]
735735
# index/series like
736736
elif hasattr(other, '_typ'):
@@ -776,8 +776,8 @@ cdef class _Period(object):
776776
offsets.Tick, offsets.DateOffset,
777777
Timedelta)):
778778
return self._add_delta(other)
779-
elif other is tslib.NaT:
780-
return tslib.NaT
779+
elif other is NaT:
780+
return NaT
781781
elif lib.is_integer(other):
782782
ordinal = self.ordinal + other * self.freq.n
783783
return Period(ordinal=ordinal, freq=self.freq)
@@ -808,8 +808,8 @@ cdef class _Period(object):
808808
else: # pragma: no cover
809809
return NotImplemented
810810
elif isinstance(other, Period):
811-
if self is tslib.NaT:
812-
return tslib.NaT
811+
if self is NaT:
812+
return NaT
813813
return NotImplemented
814814
else:
815815
return NotImplemented
@@ -1164,7 +1164,7 @@ class Period(_Period):
11641164
if (year is None and month is None and
11651165
quarter is None and day is None and
11661166
hour is None and minute is None and second is None):
1167-
ordinal = tslib.iNaT
1167+
ordinal = iNaT
11681168
else:
11691169
if freq is None:
11701170
raise ValueError("If value is None, freq cannot be None")
@@ -1190,7 +1190,7 @@ class Period(_Period):
11901190
ordinal = converted.ordinal
11911191

11921192
elif is_null_datetimelike(value) or value in tslib._nat_strings:
1193-
ordinal = tslib.iNaT
1193+
ordinal = iNaT
11941194

11951195
elif isinstance(value, compat.string_types) or lib.is_integer(value):
11961196
if lib.is_integer(value):

pandas/src/ujson/python/objToJSON.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void initObjToJSON(void)
180180
Py_DECREF(mod_pandas);
181181
}
182182

183-
mod_tslib = PyImport_ImportModule("pandas.tslib");
183+
mod_tslib = PyImport_ImportModule("pandas.libs.tslib");
184184
if (mod_tslib) {
185185
cls_nat = (PyTypeObject *)PyObject_GetAttrString(mod_tslib, "NaTType");
186186
Py_DECREF(mod_tslib);

pandas/tests/api/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestPDApi(Base, tm.TestCase):
3838

3939
# top-level packages that are c-imports, should rename to _*
4040
# to avoid naming conflicts
41-
lib_to_rename = ['algos', 'hashtable', 'lib', 'index']
41+
lib_to_rename = ['algos', 'hashtable', 'lib']
4242

4343
# these are already deprecated; awaiting removal
4444
deprecated_modules = ['stats', 'datetools', 'parser', 'json']

pandas/tests/frame/test_indexing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
date_range)
1919
import pandas as pd
2020

21+
from pandas.libs.tslib import iNaT
2122
from pandas.tseries.offsets import BDay
2223
from pandas.types.common import (is_float_dtype,
2324
is_integer,
@@ -1491,8 +1492,7 @@ def test_setitem_single_column_mixed_datetime(self):
14911492
assert_series_equal(result, expected)
14921493

14931494
# set an allowable datetime64 type
1494-
from pandas import tslib
1495-
df.loc['b', 'timestamp'] = tslib.iNaT
1495+
df.loc['b', 'timestamp'] = iNaT
14961496
self.assertTrue(isnull(df.loc['b', 'timestamp']))
14971497

14981498
# allow this syntax

pandas/tests/indexes/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def test_numpy_argsort(self):
408408
# pandas compatibility input validation - the
409409
# rest already perform separate (or no) such
410410
# validation via their 'values' attribute as
411-
# defined in pandas/indexes/base.py - they
411+
# defined in pandas.indexes/base.py - they
412412
# cannot be changed at the moment due to
413413
# backwards compatibility concerns
414414
if isinstance(type(ind), (CategoricalIndex, RangeIndex)):

pandas/tests/indexes/datetimes/test_construction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
from datetime import timedelta
33

44
import pandas as pd
5-
from pandas import tslib, offsets, lib
5+
from pandas import offsets, lib
66
import pandas.util.testing as tm
7+
from pandas.libs import tslib
78
from pandas.libs.tslib import OutOfBoundsDatetime
89
from pandas import (DatetimeIndex, Index, Timestamp, datetime, date_range,
910
to_datetime)

pandas/tests/indexes/datetimes/test_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
117117

118118
def test_time_loc(self): # GH8667
119119
from datetime import time
120-
from pandas.index import _SIZE_CUTOFF
120+
from pandas.libs.index import _SIZE_CUTOFF
121121

122122
ns = _SIZE_CUTOFF + np.array([-100, 100], dtype=np.int64)
123123
key = time(15, 11, 30)

pandas/tests/indexes/datetimes/test_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from distutils.version import LooseVersion
1010

1111
import pandas as pd
12-
from pandas import tslib
12+
from pandas.libs import tslib
1313
from pandas.tseries import tools
1414
from pandas.tseries.tools import normalize_date
1515
from pandas.compat import lmap

pandas/tests/indexes/period/test_indexing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import pandas as pd
55
from pandas.util import testing as tm
66
from pandas.compat import lrange
7+
from pandas.libs import tslib
78
from pandas import (PeriodIndex, Series, DatetimeIndex,
8-
period_range, Period, tslib, _np_version_under1p9)
9+
period_range, Period, _np_version_under1p9)
910

1011

1112
class TestGetItem(tm.TestCase):

pandas/tests/indexes/timedeltas/test_construction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
import pandas as pd
55
import pandas.util.testing as tm
6-
from pandas import TimedeltaIndex, timedelta_range, tslib, to_timedelta
7-
8-
iNaT = tslib.iNaT
6+
from pandas import TimedeltaIndex, timedelta_range, to_timedelta
7+
from pandas.libs.tslib import iNaT
98

109

1110
class TestTimedeltaIndex(tm.TestCase):

pandas/tests/indexes/timedeltas/test_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from pandas.util.testing import assert_series_equal, assert_frame_equal
99
from pandas import (Series, Timedelta, DataFrame, Timestamp, TimedeltaIndex,
1010
timedelta_range, date_range, DatetimeIndex, Int64Index,
11-
_np_version_under1p10, Float64Index, Index, tslib)
12-
11+
_np_version_under1p10, Float64Index, Index)
12+
from pandas.libs.tslib import iNaT
1313
from pandas.tests.test_base import Ops
1414

1515

@@ -772,7 +772,7 @@ def test_nat_new(self):
772772
tm.assert_index_equal(result, exp)
773773

774774
result = idx._nat_new(box=False)
775-
exp = np.array([tslib.iNaT] * 5, dtype=np.int64)
775+
exp = np.array([iNaT] * 5, dtype=np.int64)
776776
tm.assert_numpy_array_equal(result, exp)
777777

778778
def test_shift(self):

pandas/tests/indexes/timedeltas/test_tools.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import pandas as pd
55
import pandas.util.testing as tm
66
from pandas.util.testing import assert_series_equal
7-
from pandas import (Series, Timedelta, to_timedelta, tslib, isnull,
7+
from pandas import (Series, Timedelta, to_timedelta, isnull,
88
TimedeltaIndex)
9+
from pandas.libs.tslib import iNaT
910

1011

1112
class TestTimedeltas(tm.TestCase):
@@ -26,7 +27,7 @@ def conv(v):
2627

2728
# empty string
2829
result = to_timedelta('', box=False)
29-
self.assertEqual(result.astype('int64'), tslib.iNaT)
30+
self.assertEqual(result.astype('int64'), iNaT)
3031

3132
result = to_timedelta(['', ''])
3233
self.assertTrue(isnull(result).all())

pandas/tests/io/test_packers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from pandas.tests.test_panel import assert_panel_equal
2323

2424
import pandas
25-
from pandas import Timestamp, NaT, tslib
25+
from pandas import Timestamp, NaT
26+
from pandas.libs.tslib import iNaT
2627

2728
nan = np.nan
2829

@@ -373,7 +374,7 @@ def setUp(self):
373374
s.name = 'object'
374375
self.d['object'] = s
375376

376-
s = Series(tslib.iNaT, dtype='M8[ns]', index=range(5))
377+
s = Series(iNaT, dtype='M8[ns]', index=range(5))
377378
self.d['date'] = s
378379

379380
data = {

0 commit comments

Comments
 (0)