|
29 | 29 | import pandas.util.testing as tm
|
30 | 30 | import pandas as pd
|
31 | 31 |
|
| 32 | +from pandas.core.common import AbstractMethodError |
32 | 33 | from pandas.compat import parse_date
|
33 | 34 | import pandas.lib as lib
|
34 | 35 | from pandas import compat
|
@@ -2495,6 +2496,18 @@ def test_float_parser(self):
|
2495 | 2496 | expected = pd.DataFrame([[float(s) for s in data.split(',')]])
|
2496 | 2497 | tm.assert_frame_equal(result, expected)
|
2497 | 2498 |
|
| 2499 | + def float_precision_choices(self): |
| 2500 | + raise AbstractMethodError(self) |
| 2501 | + |
| 2502 | + def test_scientific_no_exponent(self): |
| 2503 | + # See PR 12215 |
| 2504 | + df = DataFrame.from_items([('w', ['2e']), ('x', ['3E']), |
| 2505 | + ('y', ['42e']), ('z', ['632E'])]) |
| 2506 | + data = df.to_csv(index=False) |
| 2507 | + for prec in self.float_precision_choices(): |
| 2508 | + df_roundtrip = self.read_csv(StringIO(data), float_precision=prec) |
| 2509 | + tm.assert_frame_equal(df_roundtrip, df) |
| 2510 | + |
2498 | 2511 | def test_int64_overflow(self):
|
2499 | 2512 | data = """ID
|
2500 | 2513 | 00013007854817840016671868
|
@@ -2651,6 +2664,9 @@ def read_table(self, *args, **kwds):
|
2651 | 2664 | kwds['engine'] = 'python'
|
2652 | 2665 | return read_table(*args, **kwds)
|
2653 | 2666 |
|
| 2667 | + def float_precision_choices(self): |
| 2668 | + return [None] |
| 2669 | + |
2654 | 2670 | def test_sniff_delimiter(self):
|
2655 | 2671 | text = """index|A|B|C
|
2656 | 2672 | foo|1|2|3
|
@@ -3409,6 +3425,9 @@ def test_variable_width_unicode(self):
|
3409 | 3425 | class CParserTests(ParserTests):
|
3410 | 3426 | """ base class for CParser Testsing """
|
3411 | 3427 |
|
| 3428 | + def float_precision_choices(self): |
| 3429 | + return [None, 'high', 'round_trip'] |
| 3430 | + |
3412 | 3431 | def test_buffer_overflow(self):
|
3413 | 3432 | # GH9205
|
3414 | 3433 | # test certain malformed input files that cause buffer overflows in
|
|
0 commit comments