@@ -312,7 +312,7 @@ def read_hdf(path_or_buf, key=None, mode: str = "r", **kwargs):
312
312
key : object, optional
313
313
The group identifier in the store. Can be omitted if the HDF file
314
314
contains a single pandas object.
315
- mode : {'r', 'r+', 'a'}, optional
315
+ mode : {'r', 'r+', 'a'}, default 'r'
316
316
Mode to use when opening the file. Ignored if path_or_buf is a
317
317
:class:`pandas.HDFStore`. Default is 'r'.
318
318
where : list, optional
@@ -417,7 +417,7 @@ def read_hdf(path_or_buf, key=None, mode: str = "r", **kwargs):
417
417
raise
418
418
419
419
420
- def _is_metadata_of (group , parent_group ) -> bool :
420
+ def _is_metadata_of (group : "Node" , parent_group : "Node" ) -> bool :
421
421
"""Check if a given group is a metadata group for a given parent_group."""
422
422
if group ._v_depth <= parent_group ._v_depth :
423
423
return False
@@ -932,9 +932,7 @@ def func(_start, _stop, _where):
932
932
# retrieve the objs, _where is always passed as a set of
933
933
# coordinates here
934
934
objs = [
935
- t .read (
936
- where = _where , columns = columns , start = _start , stop = _stop , ** kwargs
937
- )
935
+ t .read (where = _where , columns = columns , start = _start , stop = _stop )
938
936
for t in tbls
939
937
]
940
938
@@ -957,7 +955,7 @@ def func(_start, _stop, _where):
957
955
958
956
return it .get_result (coordinates = True )
959
957
960
- def put (self , key : str , value , format = None , append = False , ** kwargs ):
958
+ def put (self , key : str , value : FrameOrSeries , format = None , append = False , ** kwargs ):
961
959
"""
962
960
Store object in HDFStore.
963
961
@@ -986,8 +984,8 @@ def put(self, key: str, value, format=None, append=False, **kwargs):
986
984
"""
987
985
if format is None :
988
986
format = get_option ("io.hdf.default_format" ) or "fixed"
989
- kwargs = self ._validate_format (format , kwargs )
990
- self ._write_to_group (key , value , append = append , ** kwargs )
987
+ format = self ._validate_format (format )
988
+ self ._write_to_group (key , value , format = format , append = append , ** kwargs )
991
989
992
990
def remove (self , key : str , where = None , start = None , stop = None ):
993
991
"""
@@ -1046,7 +1044,7 @@ def remove(self, key: str, where=None, start=None, stop=None):
1046
1044
def append (
1047
1045
self ,
1048
1046
key : str ,
1049
- value ,
1047
+ value : FrameOrSeries ,
1050
1048
format = None ,
1051
1049
append = True ,
1052
1050
columns = None ,
@@ -1096,8 +1094,10 @@ def append(
1096
1094
dropna = get_option ("io.hdf.dropna_table" )
1097
1095
if format is None :
1098
1096
format = get_option ("io.hdf.default_format" ) or "table"
1099
- kwargs = self ._validate_format (format , kwargs )
1100
- self ._write_to_group (key , value , append = append , dropna = dropna , ** kwargs )
1097
+ format = self ._validate_format (format )
1098
+ self ._write_to_group (
1099
+ key , value , format = format , append = append , dropna = dropna , ** kwargs
1100
+ )
1101
1101
1102
1102
def append_to_multiple (
1103
1103
self ,
@@ -1418,17 +1418,16 @@ def _check_if_open(self):
1418
1418
if not self .is_open :
1419
1419
raise ClosedFileError (f"{ self ._path } file is not open!" )
1420
1420
1421
- def _validate_format (self , format : str , kwargs : Dict [str , Any ]) -> Dict [str , Any ]:
1422
- """ validate / deprecate formats; return the new kwargs """
1423
- kwargs = kwargs .copy ()
1421
+ def _validate_format (self , format : str ) -> str :
1422
+ """ validate / deprecate formats """
1424
1423
1425
1424
# validate
1426
1425
try :
1427
- kwargs [ " format" ] = _FORMAT_MAP [format .lower ()]
1426
+ format = _FORMAT_MAP [format .lower ()]
1428
1427
except KeyError :
1429
1428
raise TypeError (f"invalid HDFStore format specified [{ format } ]" )
1430
1429
1431
- return kwargs
1430
+ return format
1432
1431
1433
1432
def _create_storer (
1434
1433
self ,
@@ -1532,7 +1531,7 @@ def error(t):
1532
1531
def _write_to_group (
1533
1532
self ,
1534
1533
key : str ,
1535
- value ,
1534
+ value : FrameOrSeries ,
1536
1535
format ,
1537
1536
axes = None ,
1538
1537
index = True ,
@@ -1615,10 +1614,10 @@ def _write_to_group(
1615
1614
if isinstance (s , Table ) and index :
1616
1615
s .create_index (columns = index )
1617
1616
1618
- def _read_group (self , group : "Node" , ** kwargs ):
1617
+ def _read_group (self , group : "Node" ):
1619
1618
s = self ._create_storer (group )
1620
1619
s .infer_axes ()
1621
- return s .read (** kwargs )
1620
+ return s .read ()
1622
1621
1623
1622
1624
1623
class TableIterator :
@@ -2752,28 +2751,22 @@ def f(values, freq=None, tz=None):
2752
2751
2753
2752
return klass
2754
2753
2755
- def validate_read (self , kwargs : Dict [ str , Any ]) -> Dict [ str , Any ] :
2754
+ def validate_read (self , columns , where ) :
2756
2755
"""
2757
- remove table keywords from kwargs and return
2758
2756
raise if any keywords are passed which are not-None
2759
2757
"""
2760
- kwargs = copy .copy (kwargs )
2761
-
2762
- columns = kwargs .pop ("columns" , None )
2763
2758
if columns is not None :
2764
2759
raise TypeError (
2765
2760
"cannot pass a column specification when reading "
2766
2761
"a Fixed format store. this store must be "
2767
2762
"selected in its entirety"
2768
2763
)
2769
- where = kwargs .pop ("where" , None )
2770
2764
if where is not None :
2771
2765
raise TypeError (
2772
2766
"cannot pass a where specification when reading "
2773
2767
"from a Fixed format store. this store must be "
2774
2768
"selected in its entirety"
2775
2769
)
2776
- return kwargs
2777
2770
2778
2771
@property
2779
2772
def is_exists (self ) -> bool :
@@ -3085,7 +3078,7 @@ def read(
3085
3078
start : Optional [int ] = None ,
3086
3079
stop : Optional [int ] = None ,
3087
3080
):
3088
- self .validate_read ({ "where" : where , "columns" : columns } )
3081
+ self .validate_read (columns , where )
3089
3082
index = self .read_index ("index" , start = start , stop = stop )
3090
3083
values = self .read_array ("values" , start = start , stop = stop )
3091
3084
return Series (values , index = index , name = self .name )
@@ -3142,7 +3135,7 @@ def read(
3142
3135
stop : Optional [int ] = None ,
3143
3136
):
3144
3137
# start, stop applied to rows, so 0th axis only
3145
- self .validate_read ({ " columns" : columns , " where" : where } )
3138
+ self .validate_read (columns , where )
3146
3139
select_axis = self .obj_type ()._get_block_manager_axis (0 )
3147
3140
3148
3141
axes = []
0 commit comments