sfu-db / dataprep

Open-source low code data preparation library in python. Collect, clean and visualization your data in python with a few lines of code.
http://dataprep.ai
MIT License
1.99k stars 203 forks source link

Cleaning latitude and longitude DMS coordinates outputs NaN when minutes or seconds equal 60 #805

Closed csital closed 2 years ago

csital commented 2 years ago

Bug Cleaning latitude and longitude fails (outputs NaN) when cleaning degrees, minutes, seconds (DMS) coordinates if minutes or seconds equals 60.

Code example to reproduce

import pandas as pd
from dataprep.clean import clean_lat_long

df = pd.DataFrame(
    {
        "lat": [
            "34° 52′ 60″ N",
            "34° 52′ 60″ N",
            "21° 29′ 60″ N",
            "51° 29′ 60″ N",
            "34° 52′ 59″ N",
            "21° 60′ 59″ N",
            "51° 60′ 59″ N",
            "51.4934° N",
        ],
        "long": [
            "10° 0′ 0″ E",
            "10° 0′ 60″ E",
            "62° 40′ 60″ E",
            "126° 50′ 60″ E",
            "10° 0′ 59″ E",
            "62° 40′ 59″ E",
            "126° 50′ 59″ E",
            "0.0098° E",
        ],
    }
)

clean_lat_long(df, lat_col='lat', long_col='long')

Output image

Desktop