0

We have a python script that does requests on an API. Now this works for lots of situations, but for one API I get an unwanted response. This is actually an error on their side, but I need to fix it on my side unfortunately.

Both in Python and Postman, the response I get is:

[{"id":123456789,"name":"Grand Café Beer"}]

Chardet says it's Ascii. Now I know I should be able to change this to the right Grand Café Beer what it should look like, but I cannot get the right combination of encode() decode() to change it. Can you help me?

Answer as directed by @iain-shelvington:

for c in df.columns: 
    if df[c].dtype == pd.StringDtype(): 
        df[c] = df[c].apply(lambda x: pd.NA if pd.isna(x) else html.unescape(x))
JasperKPI
  • 11
  • 2
  • Yes, that was the exact answer. Of course it was HTML decoding, I should have seen that. For future reference, I fixed it (in a bigger code of course) with: for c in df.columns: if df[c].dtype == pd.StringDtype(): df[c] = df[c].apply(lambda x: pd.NA if pd.isna(x) else html.unescape(x)) – JasperKPI Aug 18 '21 at 09:41

0 Answers0