@@ -87,7 +87,7 @@ def test_info_verbose():
87
87
frame .info (verbose = True , buf = buf )
88
88
89
89
res = buf .getvalue ()
90
- header = " # Column Dtype \n --- ------ ----- "
90
+ header = " # Column Dtype \n --- ------ ----- "
91
91
assert header in res
92
92
93
93
frame .info (verbose = True , buf = buf )
@@ -101,6 +101,64 @@ def test_info_verbose():
101
101
assert line .startswith (line_nr )
102
102
103
103
104
+ @pytest .mark .parametrize (
105
+ "size, header_exp, separator_exp, first_line_exp, last_line_exp" ,
106
+ [
107
+ (
108
+ 4 ,
109
+ " # Column Non-Null Count Dtype " ,
110
+ "--- ------ -------------- ----- " ,
111
+ " 0 0 3 non-null float64" ,
112
+ " 3 3 3 non-null float64" ,
113
+ ),
114
+ (
115
+ 11 ,
116
+ " # Column Non-Null Count Dtype " ,
117
+ "--- ------ -------------- ----- " ,
118
+ " 0 0 3 non-null float64" ,
119
+ " 10 10 3 non-null float64" ,
120
+ ),
121
+ (
122
+ 101 ,
123
+ " # Column Non-Null Count Dtype " ,
124
+ "--- ------ -------------- ----- " ,
125
+ " 0 0 3 non-null float64" ,
126
+ " 100 100 3 non-null float64" ,
127
+ ),
128
+ (
129
+ 1001 ,
130
+ " # Column Non-Null Count Dtype " ,
131
+ "--- ------ -------------- ----- " ,
132
+ " 0 0 3 non-null float64" ,
133
+ " 1000 1000 3 non-null float64" ,
134
+ ),
135
+ (
136
+ 10001 ,
137
+ " # Column Non-Null Count Dtype " ,
138
+ "--- ------ -------------- ----- " ,
139
+ " 0 0 3 non-null float64" ,
140
+ " 10000 10000 3 non-null float64" ,
141
+ ),
142
+ ],
143
+ )
144
+ def test_info_verbose_with_counts_spacing (
145
+ size , header_exp , separator_exp , first_line_exp , last_line_exp
146
+ ):
147
+ """Test header column, spacer, first line and last line in verbose mode."""
148
+ frame = DataFrame (np .random .randn (3 , size ))
149
+ buf = StringIO ()
150
+ frame .info (verbose = True , null_counts = True , buf = buf )
151
+ all_lines = buf .getvalue ().splitlines ()
152
+ # Here table would contain only header, separator and table lines
153
+ # dframe repr, index summary, memory usage and dtypes are excluded
154
+ table = all_lines [3 :- 2 ]
155
+ header , separator , first_line , * rest , last_line = table
156
+ assert header == header_exp
157
+ assert separator == separator_exp
158
+ assert first_line == first_line_exp
159
+ assert last_line == last_line_exp
160
+
161
+
104
162
def test_info_memory ():
105
163
# https://github.com/pandas-dev/pandas/issues/21056
106
164
df = DataFrame ({"a" : Series ([1 , 2 ], dtype = "i8" )})
0 commit comments