1

When I convert my dataframe to list, I get the below reponse. I want to remove the apostrophes i.e. 'Date(2018,11,09)' should look like Date(2018,11,09).

new_df = df.values.tolist()

Output-

[[68.0, 86.0, 'Date(2018, 11, 09)'], [40.0, 56.0, 'Date(2018, 11, 10)'], [34.0, 25.0, 'Date(2018, 11, 11)'].......]

This question is close to what I'm looking for but in my scenario, it is not an integer.

Desired output -

[[68.0, 86.0, Date(2018, 11, 09)], [40.0, 56.0, Date(2018, 11, 10)], [34.0, 25.0, Date(2018, 11, 11)].......]

Datatype -

             Sender 
Message        User1    float64
               User2    float64
js_ready_date              object
dtype: object
Pirate X
  • 3,023
  • 5
  • 33
  • 60

1 Answers1

3

This question and answer might be helpful.

Python interpreter returns a string with quotes.

>>> a = [68.0, 86.0, 'Date(2018, 11, 09)']
>>> a[2]
'Date(2018, 11, 09)'
>>> print(a[2])
Date(2018, 11, 09)

Therefore if you use a string in Python, there is no other way to store a string without quotes.

Sihyeon Kim
  • 161
  • 7