tintin
tintin

Reputation: 11

How to remove 'u'(unicode) from all the values in a column in a DataFrame?

How does one remove 'u'(unicode) from all the values in a column in a DataFrame?

table.place.unique()


array([u'Newyork', u'Chicago', u'San Francisco'], dtype=object)

Upvotes: 1

Views: 6482

Answers (1)

Kracit
Kracit

Reputation: 1728

>>> df = pd.DataFrame([u'c%s'%i for i in range(11,21)], columns=["c"])
>>> df
     c
0  c11
1  c12
2  c13
3  c14
4  c15
5  c16
6  c17
7  c18
8  c19
9  c20
>>> df['c'].values
array([u'c11', u'c12', u'c13', u'c14', u'c15', u'c16', u'c17', u'c18',
       u'c19', u'c20'], dtype=object)
>>> df['c'].astype(str).values
array(['c11', 'c12', 'c13', 'c14', 'c15', 'c16', 'c17', 'c18', 'c19', 'c20'], dtype=object)
>>>

Upvotes: 2

Related Questions