15
15
16
16
import numpy as np
17
17
18
- from pandas ._libs import algos , lib , writers as libwriters
18
+ from pandas ._libs import lib , writers as libwriters
19
19
from pandas ._libs .tslibs import timezones
20
20
from pandas .compat import PY3 , filter , lrange , range , string_types
21
21
from pandas .errors import PerformanceWarning
22
22
23
23
from pandas .core .dtypes .common import (
24
- ensure_int64 , ensure_object , ensure_platform_int , is_categorical_dtype ,
25
- is_datetime64_dtype , is_datetime64tz_dtype , is_list_like ,
26
- is_timedelta64_dtype )
24
+ ensure_object , is_categorical_dtype , is_datetime64_dtype ,
25
+ is_datetime64tz_dtype , is_list_like , is_timedelta64_dtype )
27
26
from pandas .core .dtypes .missing import array_equivalent
28
27
29
28
from pandas import (
30
- DataFrame , DatetimeIndex , Index , Int64Index , MultiIndex , Panel ,
31
- PeriodIndex , Series , SparseDataFrame , SparseSeries , TimedeltaIndex , compat ,
32
- concat , isna , to_datetime )
29
+ DataFrame , DatetimeIndex , Index , Int64Index , MultiIndex , PeriodIndex ,
30
+ Series , SparseDataFrame , SparseSeries , TimedeltaIndex , compat , concat ,
31
+ isna , to_datetime )
33
32
from pandas .core import config
34
- from pandas .core .algorithms import unique
35
- from pandas .core .arrays .categorical import (
36
- Categorical , _factorize_from_iterables )
33
+ from pandas .core .arrays .categorical import Categorical
37
34
from pandas .core .arrays .sparse import BlockIndex , IntIndex
38
35
from pandas .core .base import StringMixin
39
36
import pandas .core .common as com
40
37
from pandas .core .computation .pytables import Expr , maybe_expression
41
38
from pandas .core .config import get_option
42
39
from pandas .core .index import ensure_index
43
- from pandas .core .internals import (
44
- BlockManager , _block2d_to_blocknd , _block_shape , _factor_indexer ,
45
- make_block )
40
+ from pandas .core .internals import BlockManager , _block_shape , make_block
46
41
47
42
from pandas .io .common import _stringify_path
48
43
from pandas .io .formats .printing import adjoin , pprint_thing
@@ -175,7 +170,6 @@ class DuplicateWarning(Warning):
175
170
SparseSeries : u'sparse_series' ,
176
171
DataFrame : u'frame' ,
177
172
SparseDataFrame : u'sparse_frame' ,
178
- Panel : u'wide' ,
179
173
}
180
174
181
175
# storer class map
@@ -187,7 +181,6 @@ class DuplicateWarning(Warning):
187
181
u'sparse_series' : 'SparseSeriesFixed' ,
188
182
u'frame' : 'FrameFixed' ,
189
183
u'sparse_frame' : 'SparseFrameFixed' ,
190
- u'wide' : 'PanelFixed' ,
191
184
}
192
185
193
186
# table class map
@@ -198,14 +191,11 @@ class DuplicateWarning(Warning):
198
191
u'appendable_frame' : 'AppendableFrameTable' ,
199
192
u'appendable_multiframe' : 'AppendableMultiFrameTable' ,
200
193
u'worm' : 'WORMTable' ,
201
- u'legacy_frame' : 'LegacyFrameTable' ,
202
- u'legacy_panel' : 'LegacyPanelTable' ,
203
194
}
204
195
205
196
# axes map
206
197
_AXES_MAP = {
207
198
DataFrame : [0 ],
208
- Panel : [1 , 2 ]
209
199
}
210
200
211
201
# register our configuration options
@@ -864,7 +854,7 @@ def put(self, key, value, format=None, append=False, **kwargs):
864
854
Parameters
865
855
----------
866
856
key : object
867
- value : {Series, DataFrame, Panel }
857
+ value : {Series, DataFrame}
868
858
format : 'fixed(f)|table(t)', default is 'fixed'
869
859
fixed(f) : Fixed format
870
860
Fast writing/reading. Not-appendable, nor searchable
@@ -946,7 +936,7 @@ def append(self, key, value, format=None, append=True, columns=None,
946
936
Parameters
947
937
----------
948
938
key : object
949
- value : {Series, DataFrame, Panel }
939
+ value : {Series, DataFrame}
950
940
format : 'table' is the default
951
941
table(t) : table format
952
942
Write as a PyTables Table structure which may perform
@@ -3027,16 +3017,6 @@ class FrameFixed(BlockManagerFixed):
3027
3017
obj_type = DataFrame
3028
3018
3029
3019
3030
- class PanelFixed (BlockManagerFixed ):
3031
- pandas_kind = u'wide'
3032
- obj_type = Panel
3033
- is_shape_reversed = True
3034
-
3035
- def write (self , obj , ** kwargs ):
3036
- obj ._consolidate_inplace ()
3037
- return super (PanelFixed , self ).write (obj , ** kwargs )
3038
-
3039
-
3040
3020
class Table (Fixed ):
3041
3021
3042
3022
""" represent a table:
@@ -3899,85 +3879,11 @@ def read(self, where=None, columns=None, **kwargs):
3899
3879
if not self .read_axes (where = where , ** kwargs ):
3900
3880
return None
3901
3881
3902
- lst_vals = [a .values for a in self .index_axes ]
3903
- labels , levels = _factorize_from_iterables (lst_vals )
3904
- # labels and levels are tuples but lists are expected
3905
- labels = list (labels )
3906
- levels = list (levels )
3907
- N = [len (lvl ) for lvl in levels ]
3908
-
3909
- # compute the key
3910
- key = _factor_indexer (N [1 :], labels )
3911
-
3912
- objs = []
3913
- if len (unique (key )) == len (key ):
3914
-
3915
- sorter , _ = algos .groupsort_indexer (
3916
- ensure_int64 (key ), np .prod (N ))
3917
- sorter = ensure_platform_int (sorter )
3918
-
3919
- # create the objs
3920
- for c in self .values_axes :
3921
-
3922
- # the data need to be sorted
3923
- sorted_values = c .take_data ().take (sorter , axis = 0 )
3924
- if sorted_values .ndim == 1 :
3925
- sorted_values = sorted_values .reshape (
3926
- (sorted_values .shape [0 ], 1 ))
3927
-
3928
- take_labels = [l .take (sorter ) for l in labels ]
3929
- items = Index (c .values )
3930
- block = _block2d_to_blocknd (
3931
- values = sorted_values , placement = np .arange (len (items )),
3932
- shape = tuple (N ), labels = take_labels , ref_items = items )
3933
-
3934
- # create the object
3935
- mgr = BlockManager ([block ], [items ] + levels )
3936
- obj = self .obj_type (mgr )
3937
-
3938
- # permute if needed
3939
- if self .is_transposed :
3940
- obj = obj .transpose (
3941
- * tuple (Series (self .data_orientation ).argsort ()))
3942
-
3943
- objs .append (obj )
3944
-
3945
- else :
3946
- raise NotImplementedError ("Panel is removed in pandas 0.25.0" )
3947
-
3948
- # create the composite object
3949
- if len (objs ) == 1 :
3950
- wp = objs [0 ]
3951
- else :
3952
- wp = concat (objs , axis = 0 , verify_integrity = False )._consolidate ()
3953
-
3954
- # apply the selection filters & axis orderings
3955
- wp = self .process_axes (wp , columns = columns )
3956
-
3957
- return wp
3958
-
3959
-
3960
- class LegacyFrameTable (LegacyTable ):
3961
-
3962
- """ support the legacy frame table """
3963
- pandas_kind = u'frame_table'
3964
- table_type = u'legacy_frame'
3965
- obj_type = Panel
3966
-
3967
- def read (self , * args , ** kwargs ):
3968
- return super (LegacyFrameTable , self ).read (* args , ** kwargs )['value' ]
3969
-
3970
-
3971
- class LegacyPanelTable (LegacyTable ):
3972
-
3973
- """ support the legacy panel table """
3974
- table_type = u'legacy_panel'
3975
- obj_type = Panel
3882
+ raise NotImplementedError ("Panel is removed in pandas 0.25.0" )
3976
3883
3977
3884
3978
3885
class AppendableTable (LegacyTable ):
3979
-
3980
- """ suppor the new appendable table formats """
3886
+ """ support the new appendable table formats """
3981
3887
_indexables = None
3982
3888
table_type = u'appendable'
3983
3889
@@ -4209,8 +4115,7 @@ def delete(self, where=None, start=None, stop=None, **kwargs):
4209
4115
4210
4116
4211
4117
class AppendableFrameTable (AppendableTable ):
4212
-
4213
- """ suppor the new appendable table formats """
4118
+ """ support the new appendable table formats """
4214
4119
pandas_kind = u'frame_table'
4215
4120
table_type = u'appendable_frame'
4216
4121
ndim = 2
0 commit comments