File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -245,7 +245,8 @@ Equality semantics
245
245
246
246
Two instances of :class: `~pandas.api.types.CategoricalDtype ` compare equal
247
247
whenever they have the same categories and order. When comparing two
248
- unordered categoricals, the order of the ``categories `` is not considered.
248
+ unordered categoricals, the order of the ``categories `` is not considered. Note
249
+ that categories with different dtypes are not the same.
249
250
250
251
.. ipython :: python
251
252
@@ -263,6 +264,16 @@ All instances of ``CategoricalDtype`` compare equal to the string ``'category'``
263
264
264
265
c1 == " category"
265
266
267
+ Notice that the ``categories_dtype `` should be considered, especially when comparing with
268
+ two empty ``CategoricalDtype `` instances.
269
+
270
+ .. ipython :: python
271
+
272
+ c2 = pd.Categorical(np.array([], dtype = object ))
273
+ c3 = pd.Categorical(np.array([], dtype = float ))
274
+
275
+ c2.dtype == c3.dtype
276
+
266
277
Description
267
278
-----------
268
279
You can’t perform that action at this time.
0 commit comments