Repository: geopandas/geopandas

Issue:
wrong country code ISO_3 for France in naturalearth_lowres dataset
Not sure this is the right place to mention it, but code iso_3 for France should be 'FRA' not -99.

```
    import geopandas
    path = geopandas.datasets.get_path('naturalearth_lowres')
    world = geopandas.read_file(path)
    world[world['name']=='France'].iso_a3
```




Discussion:
Could you check if this is also the case in the original data? It's from http://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-admin-0-countries/ 
The script that generates the version bundled with geopandas is in https://github.com/geopandas/geopandas/blob/master/geopandas/datasets/naturalearth_creation.py

If it something in the actual data, you can report issues with that at https://github.com/nvkelso/natural-earth-vector/issues
Some related discussion: https://github.com/nvkelso/natural-earth-vector/issues/12
I have the same issue:

The following iso_a3 codes are incorrect.

```
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world[(world.pop_est>0) & (world.name!="Antarctica")]
print(world[world['iso_a3'] == '-99']['name'])
```


21         Norway
43         France
160     N. Cyprus
167    Somaliland
174        Kosovo
Name: name, dtype: object
@tommycarstensen can you check if the same issue has the original source data as mentioned above?
@martinfleis I checked and it's a problem with the data source:

```
    import geopandas as gpd
    import requests
    import os
    url = 'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_sovereignty.zip'
    url = 'https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip'
    path = os.path.basename(url)
    with open(path, 'wb') as f:
        f.write(requests.get(url).content)
    world_raw = gpd.read_file("zip://./{}".format(path))
    world_df = world_raw[
        ["POP_EST", "CONTINENT", "NAME", "ISO_A3", "GDP_MD_EST", "geometry"]
        ]
    world_df.columns = world_df.columns.str.lower()

    print(world_df[world_df['iso_a3'] == '-99']['name'])
```

6                     Dhekelia
21                  Somaliland
22                      France
53                      Norway
65                      Kosovo
133        USNB Guantanamo Bay
167                  N. Cyprus
168    Cyprus U.N. Buffer Zone
169            Siachen Glacier
170                   Baikonur
171                   Akrotiri
225          Indian Ocean Ter.
247              Coral Sea Is.
248                Spratly Is.
249              Clipperton I.
251    Ashmore and Cartier Is.
252            Bajo Nuevo Bank
253            Serranilla Bank
254           Scarborough Reef

I noticed this page:
http://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-admin-0-countries/

> Countries distinguish between metropolitan (homeland) and independent and semi-independent portions of sovereign states. If you want to see the dependent overseas regions broken out (like in ISO codes, see France for example), use map units instead.

But France has an ISO alpha3 code equal to the string `-99` in both data sets. I've opted to manually fix it for now.

```
    world.loc[world['name'] == 'France', 'iso_a3'] = 'FRA'
    world.loc[world['name'] == 'Norway', 'iso_a3'] = 'NOR'
    world.loc[world['name'] == 'Somaliland', 'iso_a3'] = 'SOM'
    world.loc[world['name'] == 'Kosovo', 'iso_a3'] = 'RKS'
```
I don't think we want to deviate from the Natural Earth source. So if you think something is wrong, it's best to open an issue there (https://github.com/nvkelso/natural-earth-vector/issues)
Natural earth provides several ISO3-like codes for admin-0 data (e.g. `SOV_A3, ADM0_A3,...`). They introduced [ISO_A3_EH](https://github.com/nvkelso/natural-earth-vector/issues/237) for this purpose. Wouldn't it make sense to then follow NE and introduce at least one additional column for the "eh" version?  
@dieterwang It seems that `ISO_A3_EH` resolves code for France, but not for Norway or Kosovo. There's still an unresolved issue on that https://github.com/nvkelso/natural-earth-vector/issues/284, so I would wait. It looks that there are plans to fix this in 5.0.0 release.
It's 2021 and I'm still stumbling about this bug. This is really annoying, because when you want to plot a choropleth world map using `naturalearth_lowres` dataset one has to join the own data with this dataset based on the `iso_a3` column. But this will fail for several countries because of this old bug from 2019:

```
[1]: world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
[2]: print(world[world['iso_a3'] == '-99']['name'])
21         Norway
43         France
160     N. Cyprus
167    Somaliland
174        Kosovo
Name: name, dtype: object
```
The workaround at this point of time is:
```
# fix for bug https://github.com/geopandas/geopandas/issues/1041
world.loc[world['name'] == 'France', 'iso_a3'] = 'FRA'
world.loc[world['name'] == 'Norway', 'iso_a3'] = 'NOR'
world.loc[world['name'] == 'N. Cyprus', 'iso_a3'] = 'CYP'
world.loc[world['name'] == 'Somaliland', 'iso_a3'] = 'SOM'
world.loc[world['name'] == 'Kosovo', 'iso_a3'] = 'RKS'
```

I understand that the problem is not caused by geopandas. But it would be very nice if you could fix this issue anyway, so users of geopandas don't have to wait for another two years until https://github.com/nvkelso/natural-earth-vector/issues/284 is resolved. 




> It's 2021 and I'm still stumbling about this bug. This is really annoying, because when you want to plot a choropleth world map using `naturalearth_lowres` dataset one has to join the own data with this dataset based on the `iso_a3` column. But this will fail for several countries because of this old bug from 2019:
> 
> ```
> [1]: world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
> [2]: print(world[world['iso_a3'] == '-99']['name'])
> 21         Norway
> 43         France
> 160     N. Cyprus
> 167    Somaliland
> 174        Kosovo
> Name: name, dtype: object
> ```
> 
> The workaround at this point of time is:
> 
> ```
> # fix for bug https://github.com/geopandas/geopandas/issues/1041
> world.loc[world['name'] == 'France', 'iso_a3'] = 'FRA'
> world.loc[world['name'] == 'Norway', 'iso_a3'] = 'NOR'
> world.loc[world['name'] == 'N. Cyprus', 'iso_a3'] = 'CYP'
> world.loc[world['name'] == 'Somaliland', 'iso_a3'] = 'SOM'
> world.loc[world['name'] == 'Kosovo', 'iso_a3'] = 'RKS'
> ```
> 
> I understand that the problem is not caused by geopandas. But it would be very nice if you could fix this issue anyway, so users of geopandas don't have to wait for another two years until [nvkelso/natural-earth-vector#284](https://github.com/nvkelso/natural-earth-vector/issues/284) is resolved.

I have been running behind the same for 20 hours. Thanks for posting this. Being a beginner onto this, I was thinking myself gone wrong somewhere.
Still a problem in pandas 1.3.1+,  even though https://github.com/nvkelso/natural-earth-vector/issues/284 was fixed  in August 2021.
Workaround remains:

```
# fix for bug https://github.com/geopandas/geopandas/issues/1041
world.loc[world['name'] == 'France', 'iso_a3'] = 'FRA'
world.loc[world['name'] == 'Norway', 'iso_a3'] = 'NOR'
world.loc[world['name'] == 'N. Cyprus', 'iso_a3'] = 'CYP'
world.loc[world['name'] == 'Somaliland', 'iso_a3'] = 'SOM'
world.loc[world['name'] == 'Kosovo', 'iso_a3'] = 'RKS'

```
It was fixed but the fix is not released yet.
this should be fixed manually until the upstream fix is done.

the pros outweigh the cons.

how many people have false charts (France missing, happened to me), or lose faith in geopandas because an apparently simple issue can't be fixed.

what is the con? the con is that the manual fix is reverted when the upstream data is fixed.

> We didn't want to deviate from the original data source and assumed that it will be fixed in upstream sooner. It has been fixed (at least France was) but not released yet. We'll consider fixing it on our side for the next release (0.11.0) if the situation persists

moved from https://github.com/geopandas/geopandas/issues/2182#issuecomment-942582528
A new version of the Natural Earth datasets has been released https://github.com/nvkelso/natural-earth-vector/releases/tag/v5.0.0. Hopefully, this will fix all the issues in our data once we update our built-in file.
Hmm, so not this issue is not fixed in NaturalEarth 5.0.0. So I would suggest we update our built-in dataset and fix this manually while doing that.
Have dug into this with NaturalEarth 5.0.1.  I see two options to resolve
1. update some country codes
```
# not ideal - fix some country codes
mask = world_raw["ISO_A3"].eq("-99") & world_raw["TYPE"].isin(['Sovereign country', 'Country'])
world_raw.loc[mask, "ISO_A3"] = world_raw.loc[mask, "ADM0_A3"]
```
2. include **ADM0_A3** column as well in dataset that **geopandas** distributes

Would like input from members on preferred option and I'll generate a PR to update distributed sample geometry.

Two other points
1.  **GDP_MD_EST** has been renamed **GDP_MD**.  I would recommend that it is renamed for backward compatibility with test cases.
2. comment in **naturalearth_creation.py** is wrong, using 110m dataset not 10m dataset.


### diff option 1 ###
```
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))

world.loc[:, ["continent", "name", "iso_a3", "geometry"]].compare(
    world_df.loc[:, ["continent", "name", "iso_a3", "geometry"]]
)
```
|     | ('name', 'self')   | ('name', 'other')   |   ('iso_a3', 'self') | ('iso_a3', 'other')   |
|----:|:-------------------|:--------------------|---------------------:|:----------------------|
|  21 | nan                | nan                 |                  -99 | NOR                   |
|  43 | nan                | nan                 |                  -99 | FRA                   |
| 160 | nan                | nan                 |                  -99 | CYN                   |
| 171 | Macedonia          | North Macedonia     |                  nan | nan                   |
| 174 | nan                | nan                 |                  -99 | KOS                   |


### full code with rename ###
```
import geopandas as gpd
from pathlib import Path
import requests
import urllib

url = "https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip"
f = Path.cwd().joinpath("../geopandas/geopandas/datasets").joinpath(urllib.parse.urlparse(url).path.split("/")[-1])

if not f.exists():
    r = requests.get(url, stream=True, headers={"User-Agent": "XY"})
    with open(f, "wb") as fd:
        for chunk in r.iter_content(chunk_size=128):
            fd.write(chunk)


# assumes zipfile from naturalearthdata was downloaded to current directory
world_raw = gpd.read_file(f)

# not ideal - fix some country codes
mask = world_raw["ISO_A3"].eq("-99") & world_raw["TYPE"].isin(['Sovereign country', 'Country'])
world_raw.loc[mask, "ISO_A3"] = world_raw.loc[mask, "ADM0_A3"]

# subsets columns of interest for geopandas examples
world_df = world_raw[
    ["POP_EST", "CONTINENT", "NAME", "ISO_A3", "GDP_MD", "geometry"]
].rename(columns={"GDP_MD":"GDP_MD_EST"}) # column has changed name...
world_df.columns = world_df.columns.str.lower()
```
> include ADM0_A3 column as well in dataset that geopandas distributes

That does not have these issues? I wouldn't include both. The point of `naturalearth_lowres` being included in geopandas is to have a toy example dataset, not to provide a canonical map of the world.

I'd be personally fine with manual renaming to resolve the issues pointed out in this issue and document that there is this small deviation from the original data. 

> GDP_MD_EST has been renamed GDP_MD. I would recommend that it is renamed for backward compatibility with test cases.
> comment in naturalearth_creation.py is wrong, using 110m dataset not 10m dataset.

Yes and yes.
> That does not have these issues? I wouldn't include both. 

It's all in data definition.... but to your point simplest is to override for general simple use in way I have indicated.

> I'd be personally fine with manual renaming to resolve the issues pointed out in this issue and document that there is this small deviation from the original data.

I'll go ahead with this and generate a PR


Resolving patch:
diff --git a/geopandas/datasets/naturalearth_creation.py b/geopandas/datasets/naturalearth_creation.py
--- a/geopandas/datasets/naturalearth_creation.py
+++ b/geopandas/datasets/naturalearth_creation.py
@@ -1,19 +1,29 @@
 """
 Script that generates the included dataset 'naturalearth_lowres.shp'.
 
-Raw data: https://www.naturalearthdata.com/downloads/10m-cultural-vectors/10m-admin-0-countries/
-Current version used: version 4.1.0
+Raw data: https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
+Current version used: version 5.0.1
 """  # noqa (E501 link is longer than max line length)
 
 import geopandas as gpd
 
 # assumes zipfile from naturalearthdata was downloaded to current directory
 world_raw = gpd.read_file("zip://./ne_110m_admin_0_countries.zip")
+
+# not ideal - fix some country codes
+mask = world_raw["ISO_A3"].eq("-99") & world_raw["TYPE"].isin(
+    ["Sovereign country", "Country"]
+)
+world_raw.loc[mask, "ISO_A3"] = world_raw.loc[mask, "ADM0_A3"]
+
 # subsets columns of interest for geopandas examples
 world_df = world_raw[
-    ["POP_EST", "CONTINENT", "NAME", "ISO_A3", "GDP_MD_EST", "geometry"]
-]
+    ["POP_EST", "CONTINENT", "NAME", "ISO_A3", "GDP_MD", "geometry"]
+].rename(
+    columns={"GDP_MD": "GDP_MD_EST"}
+)  # column has changed name...
 world_df.columns = world_df.columns.str.lower()
+
 world_df.to_file(
     driver="ESRI Shapefile", filename="./naturalearth_lowres/naturalearth_lowres.shp"
 )


Test patch:
diff --git a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.1.0.feather b/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.1.0.feather
deleted file mode 100644
Binary files a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.1.0.feather and /dev/null differ
diff --git a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.1.0.parquet b/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.1.0.parquet
deleted file mode 100644
Binary files a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.1.0.parquet and /dev/null differ
diff --git a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.4.0.feather b/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.4.0.feather
deleted file mode 100644
Binary files a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.4.0.feather and /dev/null differ
diff --git a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.4.0.parquet b/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.4.0.parquet
deleted file mode 100644
Binary files a/geopandas/io/tests/data/arrow/naturalearth_lowres_top2_v0.4.0.parquet and /dev/null differ
diff --git a/geopandas/io/tests/data/arrow/test_data_v0.1.0.feather b/geopandas/io/tests/data/arrow/test_data_v0.1.0.feather
new file mode 100644
Binary files /dev/null and b/geopandas/io/tests/data/arrow/test_data_v0.1.0.feather differ
diff --git a/geopandas/io/tests/data/arrow/test_data_v0.1.0.parquet b/geopandas/io/tests/data/arrow/test_data_v0.1.0.parquet
new file mode 100644
Binary files /dev/null and b/geopandas/io/tests/data/arrow/test_data_v0.1.0.parquet differ
diff --git a/geopandas/io/tests/data/arrow/test_data_v0.4.0.feather b/geopandas/io/tests/data/arrow/test_data_v0.4.0.feather
new file mode 100644
Binary files /dev/null and b/geopandas/io/tests/data/arrow/test_data_v0.4.0.feather differ
diff --git a/geopandas/io/tests/data/arrow/test_data_v0.4.0.parquet b/geopandas/io/tests/data/arrow/test_data_v0.4.0.parquet
new file mode 100644
Binary files /dev/null and b/geopandas/io/tests/data/arrow/test_data_v0.4.0.parquet differ
diff --git a/geopandas/io/tests/test_arrow.py b/geopandas/io/tests/test_arrow.py
--- a/geopandas/io/tests/test_arrow.py
+++ b/geopandas/io/tests/test_arrow.py
@@ -12,7 +12,7 @@
 import numpy as np
 import pyproj
 from pyproj import CRS
-from shapely.geometry import box, Point
+from shapely.geometry import box, Point, MultiPolygon
 
 import geopandas
 from geopandas import GeoDataFrame, read_file, read_parquet, read_feather
@@ -687,22 +687,30 @@ def test_write_spec_version(tmpdir, format, version):
 
 @pytest.mark.parametrize("version", ["0.1.0", "0.4.0"])
 def test_read_versioned_file(version):
-    # Verify that files for different metadata spec versions can be read
-    # created for each supported version:
-    # df = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
-    # df.head(2).to_feather(DATA_PATH / 'arrow' / f'naturalearth_lowres_top2_v{METADATA_VERSION}.feather')  # noqa: E501
-    # df.head(2).to_parquet(DATA_PATH / 'arrow' / f'naturalearth_lowres_top2_v{METADATA_VERSION}.parquet')  # noqa: E501
-
+    """
+    Verify that files for different metadata spec versions can be read
+    created for each supported version:
+
+    # small dummy test dataset (not naturalearth_lowres, as this can change over time)
+    from shapely.geometry import box, MultiPolygon
+    df = geopandas.GeoDataFrame(
+        {"col_str": ["a", "b"], "col_int": [1, 2], "col_float": [0.1, 0.2]},
+        geometry=[MultiPolygon([box(0, 0, 1, 1), box(2, 2, 3, 3)]), box(4, 4, 5,5)],
+        crs="EPSG:4326",
+    )
+    df.to_feather(DATA_PATH / 'arrow' / f'test_data_v{METADATA_VERSION}.feather')  # noqa: E501
+    df.to_parquet(DATA_PATH / 'arrow' / f'test_data_v{METADATA_VERSION}.parquet')  # noqa: E501
+    """
     check_crs = Version(pyproj.__version__) >= Version("3.0.0")
 
-    expected = geopandas.read_file(get_path("naturalearth_lowres")).head(2)
-
-    df = geopandas.read_feather(
-        DATA_PATH / "arrow" / f"naturalearth_lowres_top2_v{version}.feather"
+    expected = geopandas.GeoDataFrame(
+        {"col_str": ["a", "b"], "col_int": [1, 2], "col_float": [0.1, 0.2]},
+        geometry=[MultiPolygon([box(0, 0, 1, 1), box(2, 2, 3, 3)]), box(4, 4, 5, 5)],
+        crs="EPSG:4326",
     )
+
+    df = geopandas.read_feather(DATA_PATH / "arrow" / f"test_data_v{version}.feather")
     assert_geodataframe_equal(df, expected, check_crs=check_crs)
 
-    df = geopandas.read_parquet(
-        DATA_PATH / "arrow" / f"naturalearth_lowres_top2_v{version}.parquet"
-    )
+    df = geopandas.read_parquet(DATA_PATH / "arrow" / f"test_data_v{version}.parquet")
     assert_geodataframe_equal(df, expected, check_crs=check_crs)
diff --git a/geopandas/tests/test_explore.py b/geopandas/tests/test_explore.py
--- a/geopandas/tests/test_explore.py
+++ b/geopandas/tests/test_explore.py
@@ -589,10 +589,10 @@ def test_colorbar(self):
         )
         out_str = self._fetch_map_string(m)
         assert out_str.count("#440154ff") == 16
-        assert out_str.count("#3b528bff") == 51
-        assert out_str.count("#21918cff") == 133
-        assert out_str.count("#5ec962ff") == 282
-        assert out_str.count("#fde725ff") == 18
+        assert out_str.count("#3b528bff") == 50
+        assert out_str.count("#21918cff") == 138
+        assert out_str.count("#5ec962ff") == 290
+        assert out_str.count("#fde725ff") == 6
 
         # discrete cmap
         m = self.world.explore("pop_est", legend=True, cmap="Pastel2")
@@ -609,29 +609,33 @@ def test_colorbar(self):
 
     @pytest.mark.skipif(not BRANCA_05, reason="requires branca >= 0.5.0")
     def test_colorbar_max_labels(self):
+        import re
+
         # linear
         m = self.world.explore("pop_est", legend_kwds=dict(max_labels=3))
         out_str = self._fetch_map_string(m)
-
-        tick_values = [140.0, 465176713.5921569, 930353287.1843138]
-        for tick in tick_values:
-            assert str(tick) in out_str
+        tick_str = re.search(r"tickValues\(\[[\',\,\.,0-9]*\]\)", out_str).group(0)
+        assert (
+            tick_str.replace(",''", "")
+            == "tickValues([140.0,471386328.07843137,942772516.1568627])"
+        )
 
         # scheme
         m = self.world.explore(
             "pop_est", scheme="headtailbreaks", legend_kwds=dict(max_labels=3)
         )
         out_str = self._fetch_map_string(m)
-
-        assert "tickValues([140,'',182567501.0,'',1330619341.0,''])" in out_str
+        assert "tickValues([140.0,'',184117213.1818182,'',1382066377.0,''])" in out_str
 
         # short cmap
         m = self.world.explore("pop_est", legend_kwds=dict(max_labels=3), cmap="tab10")
         out_str = self._fetch_map_string(m)
 
-        tick_values = [140.0, 551721192.4, 1103442244.8]
-        for tick in tick_values:
-            assert str(tick) in out_str
+        tick_str = re.search(r"tickValues\(\[[\',\,\.,0-9]*\]\)", out_str).group(0)
+        assert (
+            tick_str
+            == "tickValues([140.0,'','','',559086084.0,'','','',1118172028.0,'','',''])"
+        )
 
     def test_xyzservices_providers(self):
         xyzservices = pytest.importorskip("xyzservices")
@@ -683,11 +687,11 @@ def test_mapclassify_categorical_legend(self):
         out_str = self._fetch_map_string(m)
 
         strings = [
-            "[140.00,33986655.00]",
-            "(33986655.00,105350020.00]",
-            "(105350020.00,207353391.00]",
-            "(207353391.00,326625791.00]",
-            "(326625791.00,1379302771.00]",
+            "[140.00,21803000.00]",
+            "(21803000.00,66834405.00]",
+            "(66834405.00,163046161.00]",
+            "(163046161.00,328239523.00]",
+            "(328239523.00,1397715000.00]",
             "missing",
         ]
         for s in strings:
@@ -704,11 +708,11 @@ def test_mapclassify_categorical_legend(self):
         out_str = self._fetch_map_string(m)
 
         strings = [
-            ">140.00,33986655.00",
-            ">33986655.00,105350020.00",
-            ">105350020.00,207353391.00",
-            ">207353391.00,326625791.00",
-            ">326625791.00,1379302771.00",
+            ">140.00,21803000.00",
+            ">21803000.00,66834405.00",
+            ">66834405.00,163046161.00",
+            ">163046161.00,328239523.00",
+            ">328239523.00,1397715000.00",
             "missing",
         ]
         for s in strings:
@@ -739,11 +743,11 @@ def test_mapclassify_categorical_legend(self):
         out_str = self._fetch_map_string(m)
 
         strings = [
-            ">140,33986655",
-            ">33986655,105350020",
-            ">105350020,207353391",
-            ">207353391,326625791",
-            ">326625791,1379302771",
+            ">140,21803000",
+            ">21803000,66834405",
+            ">66834405,163046161",
+            ">163046161,328239523",
+            ">328239523,1397715000",
             "missing",
         ]
         for s in strings:
@@ -789,9 +793,9 @@ def test_custom_colormaps(self):
         for s in strings:
             assert s in out_str
 
-        assert out_str.count("008000ff") == 306
-        assert out_str.count("ffff00ff") == 187
-        assert out_str.count("ff0000ff") == 190
+        assert out_str.count("008000ff") == 304
+        assert out_str.count("ffff00ff") == 188
+        assert out_str.count("ff0000ff") == 191
 
         # Using custom function colormap
         def my_color_function(field):
diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py
--- a/geopandas/tests/test_plotting.py
+++ b/geopandas/tests/test_plotting.py
@@ -1070,6 +1070,7 @@ def setup_class(cls):
             import mapclassify  # noqa
         except ImportError:
             pytest.importorskip("mapclassify")
+        cls.mc = mapclassify
         cls.classifiers = list(mapclassify.classifiers.CLASSIFIERS)
         cls.classifiers.remove("UserDefined")
         pth = get_path("naturalearth_lowres")
@@ -1090,9 +1091,8 @@ def test_legend(self):
             )
         labels = [t.get_text() for t in ax.get_legend().get_texts()]
         expected = [
-            "       140.00,    5217064.00",
-            "   5217064.00,   19532732.33",
-            "  19532732.33, 1379302771.00",
+            s.split("|")[0][1:-2]
+            for s in str(self.mc.Quantiles(self.df["pop_est"], k=3)).split("\n")[4:]
         ]
         assert labels == expected
 
@@ -1174,7 +1174,13 @@ def test_classification_kwds(self):
             legend=True,
         )
         labels = [t.get_text() for t in ax.get_legend().get_texts()]
-        expected = ["       140.00,    9961396.00", "   9961396.00, 1379302771.00"]
+        expected = [
+            s.split("|")[0][1:-2]
+            for s in str(self.mc.Percentiles(self.df["pop_est"], pct=[50, 100])).split(
+                "\n"
+            )[4:]
+        ]
+
         assert labels == expected
 
     def test_invalid_scheme(self):