@@ -3402,7 +3402,7 @@ def test_from_records_misc_brokenness(self):
3402
3402
df2_obj = DataFrame .from_records (rows , columns = ['date' , 'test' ])
3403
3403
results = df2_obj .get_dtype_counts ()
3404
3404
expected = Series ({ 'datetime64[ns]' : 1 , 'int64' : 1 })
3405
-
3405
+
3406
3406
def test_to_records_floats (self ):
3407
3407
df = DataFrame (np .random .rand (10 , 10 ))
3408
3408
df .to_records ()
@@ -4498,12 +4498,14 @@ def test_to_csv_from_csv(self):
4498
4498
def test_to_csv_moar (self ):
4499
4499
from pandas .util .testing import makeCustomDataframe as mkdf
4500
4500
path = '__tmp_to_csv_moar__'
4501
+ chunksize = 1000
4502
+
4501
4503
def _do_test (df ,path ,r_dtype = None ,c_dtype = None ,rnlvl = None ,cnlvl = None ,
4502
4504
dupe_col = False ):
4503
4505
4504
4506
with ensure_clean (path ) as path :
4505
- df .to_csv (path ,encoding = 'utf8' )
4506
- recons = DataFrame .from_csv (path )
4507
+ df .to_csv (path ,encoding = 'utf8' , chunksize = chunksize )
4508
+ recons = DataFrame .from_csv (path , parse_dates = False )
4507
4509
4508
4510
def _to_uni (x ):
4509
4511
if not isinstance (x ,unicode ):
@@ -4561,13 +4563,34 @@ def stuple_to_tuple(x):
4561
4563
recons .columns = np .array (recons .columns ,dtype = c_dtype )
4562
4564
df .columns = np .array (df .columns ,dtype = c_dtype )
4563
4565
4564
- assert_frame_equal (df , recons ,check_names = False )
4566
+ assert_frame_equal (df , recons ,check_names = False , check_less_precise = True )
4565
4567
4566
4568
4567
4569
N = 100
4568
4570
4571
+ for ncols in [128 ]:
4572
+ base = int ((chunksize // ncols or 1 ) or 1 )
4573
+ for nrows in [2 ,10 ,N - 1 ,N ,N + 1 ,N + 2 ,2 * N - 2 ,2 * N - 1 ,2 * N ,2 * N + 1 ,2 * N + 2 ,
4574
+ base - 1 ,base ,base + 1 ]:
4575
+ _do_test (mkdf (nrows , ncols ,r_idx_type = 'dt' ,
4576
+ c_idx_type = 's' ),path , 'dt' ,'s' )
4577
+
4578
+ # pending GH3173
4579
+ # for r_idx_type in ['i', 'f','s','u']:
4580
+ # for c_idx_type in ['i', 'f','s','u','dt']:
4581
+
4582
+ for r_idx_type in ['i' ,'s' ,'u' ]:
4583
+ for c_idx_type in ['i' , 's' ,'u' ,'dt' ]:
4584
+ for ncols in [1 ,2 ,128 ]:
4585
+ base = int ((chunksize // ncols or 1 ) or 1 )
4586
+ for nrows in [2 ,10 ,N - 1 ,N ,N + 1 ,N + 2 ,2 * N - 2 ,2 * N - 1 ,2 * N ,2 * N + 1 ,2 * N + 2 ,
4587
+ base - 1 ,base ,base + 1 ]:
4588
+ _do_test (mkdf (nrows , ncols ,r_idx_type = r_idx_type ,
4589
+ c_idx_type = c_idx_type ),path ,r_idx_type ,c_idx_type )
4590
+
4591
+
4569
4592
for ncols in [1 ,10 ,30 ]:
4570
- base = int ((100000 / ncols or 1 ) or 1 )
4593
+ base = int ((chunksize / / ncols or 1 ) or 1 )
4571
4594
for nrows in [10 ,N - 2 ,N - 1 ,N ,N + 1 ,N + 2 ,2 * N - 2 ,2 * N - 1 ,2 * N ,2 * N + 1 ,2 * N + 2 ,
4572
4595
base - 1 ,base ,base + 1 ]:
4573
4596
print ( nrows ,ncols )
@@ -4585,18 +4608,11 @@ def stuple_to_tuple(x):
4585
4608
df .columns = cols
4586
4609
_do_test (df ,path ,dupe_col = True )
4587
4610
4588
- for r_idx_type in ['i' , 'f' ,'s' ,'u' ,'dt' ]:
4589
- for c_idx_type in ['i' , 'f' ,'s' ,'u' ,'dt' ]:
4590
- print (r_idx_type ,c_idx_type )
4591
- _do_test (mkdf (100 , 1 ,r_idx_type = r_idx_type ,
4592
- c_idx_type = c_idx_type ),path ,r_idx_type ,c_idx_type )
4593
- _do_test (mkdf (100 , 2 ,r_idx_type = r_idx_type ,
4594
- c_idx_type = c_idx_type ),path ,r_idx_type ,c_idx_type )
4595
4611
4596
4612
_do_test (DataFrame (index = range (10 )),path )
4597
- _do_test (mkdf (50001 , 2 ,r_idx_nlevels = 2 ),path ,rnlvl = 2 )
4613
+ _do_test (mkdf (chunksize // 2 + 1 , 2 ,r_idx_nlevels = 2 ),path ,rnlvl = 2 )
4598
4614
for ncols in [2 ,10 ,30 ]:
4599
- base = int (100000 / ncols )
4615
+ base = int (chunksize / /ncols )
4600
4616
for nrows in [10 ,N - 2 ,N - 1 ,N ,N + 1 ,N + 2 ,2 * N - 2 ,2 * N - 1 ,2 * N ,2 * N + 1 ,2 * N + 2 ,
4601
4617
base - 1 ,base ,base + 1 ]:
4602
4618
print (nrows , ncols )
@@ -4709,7 +4725,7 @@ def test_to_csv_boundry_conditions(self):
4709
4725
assert_frame_equal (rs , df )
4710
4726
4711
4727
df = makeTimeDataFrame (25001 )
4712
- df .to_csv (path )
4728
+ df .to_csv (path )
4713
4729
rs = pan .read_csv (path , index_col = 0 , parse_dates = True )
4714
4730
assert_frame_equal (rs , df )
4715
4731
@@ -4799,7 +4815,7 @@ def test_to_csv_unicode(self):
4799
4815
4800
4816
df = DataFrame ({u'c/\u03c3 ' : [1 , 2 , 3 ]})
4801
4817
with ensure_clean () as path :
4802
-
4818
+
4803
4819
df .to_csv (path , encoding = 'UTF-8' )
4804
4820
df2 = pan .read_csv (path , index_col = 0 , encoding = 'UTF-8' )
4805
4821
assert_frame_equal (df , df2 )
0 commit comments