pandas filters a solution for a coding error in a column

  • 2021-01-22 05:15:46
  • OfStack

This is as follows:


df = df[df['cityname']==u' The Beijing municipal ']

Remember, if using python2, 1 must be imported


import sys
 
reload(sys)
 
sys.setdefaultencoding('utf-8')

Or add u' before Chinese to indicate unicode encoding, because pandas object Chinese characters are unicode type.


Related articles: