MCPcopy
hub / github.com/pandas-dev/pandas / test_latin_encoding

Function test_latin_encoding

pandas/tests/io/pytables/test_file_handling.py:334–355  ·  view source on GitHub ↗
(temp_h5_path, dtype, val)

Source from the content-addressed store, hash-verified

332)
333@pytest.mark.parametrize("dtype", ["category", None])
334def test_latin_encoding(temp_h5_path, dtype, val):
335 enc = "latin-1"
336 nan_rep = ""
337 key = "data"
338
339 val = [x.decode(enc) if isinstance(x, bytes) else x for x in val]
340 ser = Series(val, dtype=dtype)
341
342 ser.to_hdf(temp_h5_path, key=key, format="table", encoding=enc, nan_rep=nan_rep)
343 retr = read_hdf(temp_h5_path, key)
344
345 # TODO:(3.0): once Categorical replace deprecation is enforced,
346 # we may be able to re-simplify the construction of s_nan
347 if dtype == "category":
348 if nan_rep in ser.cat.categories:
349 s_nan = ser.cat.remove_categories([nan_rep])
350 else:
351 s_nan = ser
352 else:
353 s_nan = ser.replace(nan_rep, np.nan)
354
355 tm.assert_series_equal(s_nan, retr)
356
357
358def test_multiple_open_close(temp_h5_path):

Callers

nothing calls this directly

Calls 6

SeriesClass · 0.90
read_hdfFunction · 0.90
decodeMethod · 0.80
to_hdfMethod · 0.80
remove_categoriesMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected