Aviral Srivastava
Aviral Srivastava

Reputation: 4582

How can I draw an arrow in a dataframe in pandas?

I want to draw an arrow in a cell on an excel sheet. My data is in the data frame and I would like to insert an arrow at a given cell (row, column) and then finally insert that in the excel or CSV sheet.

I thought of including UTF-8 value but couldn't get the output in normal Python shell. For instance, I found out that the utf-8 value for left arrow is U+2190 and I performed the following but could not get the arrow printed:

>>> a = 'U+2190'.encode('utf-8')
>>> a
b'U+2190'

Since I am unable to deduce how to get the corresponding character from the utf-8, I am unable to decide how to get it in the dataframe and get it printed.

Upvotes: 2

Views: 1366

Answers (2)

piRSquared
piRSquared

Reputation: 294258

Unicode escape

pd.DataFrame([['\u2190']])

   0
0  ←
'2190'

Upvotes: 3

Aviral Srivastava
Aviral Srivastava

Reputation: 4582

After referencing from here, I was able to insert an arrow in the dataframe just like any other value:

df.at[prev_class_row_counter+1, 'Dependents'] = "➜"

Upvotes: 0

Related Questions