Skip to content

Commit 54c7de2

Browse files
committed
BUG/TST: test fixes for windows compat
1 parent af85719 commit 54c7de2

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pandas/core/frame.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,10 @@ def _sanitize_column(self, key, value):
22062206
'length of index')
22072207

22082208
if not isinstance(value, np.ndarray):
2209-
value = com._asarray_tuplesafe(value)
2209+
if isinstance(value, list) and len(value) > 0:
2210+
value = com._possibly_convert_platform(value)
2211+
else:
2212+
value = com._asarray_tuplesafe(value)
22102213
elif isinstance(value, PeriodIndex):
22112214
value = value.asobject
22122215
elif value.ndim == 2:

pandas/tests/test_frame.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -4891,14 +4891,17 @@ def make_dtnat_arr(n,nnat=None):
48914891
s[-i] = NaT
48924892
s[i] = NaT
48934893
return s
4894+
48944895
# N=35000
48954896
s1=make_dtnat_arr(chunksize+5)
48964897
s2=make_dtnat_arr(chunksize+5,0)
4898+
48974899
# s3=make_dtnat_arr(chunksize+5,0)
4898-
df=DataFrame(dict(a=s1,b=s2))
4899-
df.to_csv('/tmp/1.csv',chunksize=chunksize)
4900-
recons = DataFrame.from_csv('/tmp/1.csv').convert_objects('coerce')
4901-
assert_frame_equal(df, recons,check_names=False,check_less_precise=True)
4900+
with ensure_clean('1.csv') as path:
4901+
df=DataFrame(dict(a=s1,b=s2))
4902+
df.to_csv(path,chunksize=chunksize)
4903+
recons = DataFrame.from_csv(path).convert_objects('coerce')
4904+
assert_frame_equal(df, recons,check_names=False,check_less_precise=True)
49024905

49034906
for ncols in [4]:
49044907
base = int((chunksize// ncols or 1) or 1)
@@ -6864,7 +6867,7 @@ def test_replace_convert(self):
68646867
df = DataFrame([['foo', 'bar', 'bah'], ['bar', 'foo', 'bah']])
68656868
m = {'foo': 1, 'bar': 2, 'bah': 3}
68666869
rep = df.replace(m)
6867-
expec = Series([np.int_, np.int_, np.int_])
6870+
expec = Series([ np.int64] * 3)
68686871
res = rep.dtypes
68696872
assert_series_equal(expec, res)
68706873

@@ -10079,7 +10082,6 @@ def test_insert_column_bug_4032(self):
1007910082

1008010083
result = df.rename(columns={})
1008110084
str(result)
10082-
1008310085
expected = DataFrame([[1,1.1],[2, 2.2]],columns=['a','b'])
1008410086
assert_frame_equal(result,expected)
1008510087
df.insert(0, 'c', [1.3, 2.3])

0 commit comments

Comments
 (0)