1
1
import numpy as np
2
2
import pytest
3
3
4
- import pandas .util ._test_decorators as td
5
-
6
4
import pandas as pd
7
5
from pandas import (
8
6
DataFrame ,
13
11
)
14
12
import pandas ._testing as tm
15
13
16
- # TODO td.skip_array_manager_not_yet_implemented
17
- # appending with reindexing not yet working
18
-
19
14
20
15
class TestDataFrameAppend :
21
16
def test_append_multiindex (self , multiindex_dataframe_random_data , frame_or_series ):
@@ -43,7 +38,6 @@ def test_append_empty_list(self):
43
38
tm .assert_frame_equal (result , expected )
44
39
assert result is not df # .append() should return a new object
45
40
46
- @td .skip_array_manager_not_yet_implemented
47
41
def test_append_series_dict (self ):
48
42
df = DataFrame (np .random .randn (5 , 4 ), columns = ["foo" , "bar" , "baz" , "qux" ])
49
43
@@ -84,7 +78,6 @@ def test_append_series_dict(self):
84
78
expected = df .append (df [- 1 :], ignore_index = True )
85
79
tm .assert_frame_equal (result , expected )
86
80
87
- @td .skip_array_manager_not_yet_implemented
88
81
def test_append_list_of_series_dicts (self ):
89
82
df = DataFrame (np .random .randn (5 , 4 ), columns = ["foo" , "bar" , "baz" , "qux" ])
90
83
@@ -103,7 +96,6 @@ def test_append_list_of_series_dicts(self):
103
96
expected = df .append (DataFrame (dicts ), ignore_index = True , sort = True )
104
97
tm .assert_frame_equal (result , expected )
105
98
106
- @td .skip_array_manager_not_yet_implemented
107
99
def test_append_missing_cols (self ):
108
100
# GH22252
109
101
# exercise the conditional branch in append method where the data
@@ -148,8 +140,7 @@ def test_append_empty_dataframe(self):
148
140
expected = df1 .copy ()
149
141
tm .assert_frame_equal (result , expected )
150
142
151
- @td .skip_array_manager_not_yet_implemented
152
- def test_append_dtypes (self ):
143
+ def test_append_dtypes (self , using_array_manager ):
153
144
154
145
# GH 5754
155
146
# row appends of different dtypes (so need to do by-item)
@@ -173,6 +164,10 @@ def test_append_dtypes(self):
173
164
expected = DataFrame (
174
165
{"bar" : Series ([Timestamp ("20130101" ), np .nan ], dtype = "M8[ns]" )}
175
166
)
167
+ if using_array_manager :
168
+ # TODO(ArrayManager) decide on exact casting rules in concat
169
+ # With ArrayManager, all-NaN float is not ignored
170
+ expected = expected .astype (object )
176
171
tm .assert_frame_equal (result , expected )
177
172
178
173
df1 = DataFrame ({"bar" : Timestamp ("20130101" )}, index = range (1 ))
@@ -181,6 +176,9 @@ def test_append_dtypes(self):
181
176
expected = DataFrame (
182
177
{"bar" : Series ([Timestamp ("20130101" ), np .nan ], dtype = "M8[ns]" )}
183
178
)
179
+ if using_array_manager :
180
+ # With ArrayManager, all-NaN float is not ignored
181
+ expected = expected .astype (object )
184
182
tm .assert_frame_equal (result , expected )
185
183
186
184
df1 = DataFrame ({"bar" : np .nan }, index = range (1 ))
@@ -189,6 +187,9 @@ def test_append_dtypes(self):
189
187
expected = DataFrame (
190
188
{"bar" : Series ([np .nan , Timestamp ("20130101" )], dtype = "M8[ns]" )}
191
189
)
190
+ if using_array_manager :
191
+ # With ArrayManager, all-NaN float is not ignored
192
+ expected = expected .astype (object )
192
193
tm .assert_frame_equal (result , expected )
193
194
194
195
df1 = DataFrame ({"bar" : Timestamp ("20130101" )}, index = range (1 ))
@@ -208,7 +209,6 @@ def test_append_timestamps_aware_or_naive(self, tz_naive_fixture, timestamp):
208
209
expected = Series (Timestamp (timestamp , tz = tz ), name = 0 )
209
210
tm .assert_series_equal (result , expected )
210
211
211
- @td .skip_array_manager_not_yet_implemented
212
212
@pytest .mark .parametrize (
213
213
"data, dtype" ,
214
214
[
0 commit comments