Pandas.read_csv () with special characters (accents) in column names

I have a file csvcontaining some data with column names:

  • "Period"
  • "IAS_brut"
  • "IAS_lissé"
  • "Incidence_Sentinelles"

I have a problem with the third "IAS_lissé" , which is incorrectly interpreted by the method pd.read_csv()and returned as.

What is this symbol?

Since it is generating an error in my flash application, is there any way to read this column in another way without changing the file?

In [1]: import pandas as pd

In [2]: pd.read_csv("Openhealth_S-Grippal.csv",delimiter=";").columns

Out[2]: Index([u'PERIODE', u'IAS_brut', u'IAS_liss ', u'Incidence_Sentinelles'], dtype='object')
+4
source share
1 answer

encoding read_csv, . pandas doc . python .

, utf-8 ( , ).

df = pd.read_csv("Openhealth_S-Grippal.csv", delimiter=";", encoding='utf-8')

, . , , csv , .

df = pd.read_csv('sample.csv', encoding='utf-8')

:

    IAS_lissé
0   1
1   2
2   3
+1

Source: https://habr.com/ru/post/1655551/


All Articles