title: Difficulty converting str data to int/float/decimal for plotting with matplolib
body: <p>I have extracted data from a SQL database table but have been having persistent issues with trying to plot a graph between two variables. This is due to conversion issue between data types. I have first successfully converted a <code>list</code> to a <code>str</code> data type and now I want to convert it to either a <code>float</code>/<code>int</code>/ <code>decimal</code>  type so that I can use it with matplotlib. I feel stuck at the moment since I am unable to convert the <code>str</code> data to any of them. Shown below is my script:</p>
  
  <pre><code>import mysql.connector as mariadb
  import matplotlib as mpl
  mpl.use('Agg')
  import numpy as np
  import matplotlib.mlab as mlab
  import matplotlib.pyplot as plt
  from matplotlib import pyplot
  from decimal import Decimal
  import pandas as pd
  
  mariadb_connection = mariadb.connect(user='user', password='password', database='mydatabase')
  cur = mariadb_connection.cursor()
  cur.execute("SELECT time, current FROM table1")
  
  current = []
  time = []
  
  for row in cur.fetchall():
      current.append(int(row[1]))
      time.append(str(row[0]))
  
  print(type(time)) #at this point terminal shows it is a list data type
  time = pd.to_datetime(time)
  print(type(time)) #at this point terminal shows it is a &lt;class 'pandas.core.indexes.datetimes.DatetimeIndex'&gt;data type
  
  print(type(current))  #at this point, terminal shows it is a list data type
  current=','.join(str(v) for v in current)
  print(type(current)) #at this point, terminal shows it is a str data 
  current=float(current) #at this point, I get an error stating ValueError: invalid literal for float()
  print(type(current))
  
  mariadb_connection.close()
  
  plt.figure()
  plt.plot(time, current) 
  
  plt.show()
  fig.savefig('plot.jpg')
  </code></pre>
  
  <p>On running this script, I get an error stating <code>
  ValueError: invalid literal for float(): 51,52,52,53,52,52,53,53,55,54,58,72,63,68,79,140,133,102,116,120,189,196,151,249,277,218,206,210,212,173,194,216,181,166,221,212,175,189,288,300,281,210,266</code></p>
  
  <p>I then modified the line <code>current=float(current)</code> to <code>current=int(current)</code> to try converting the <code>str</code> data to <code>int</code> type and it states another error <code>ValueError: invalid literal for int() with base 10: '51,52,52,53,.....</code></p>
  
  <p>I then also tried to convert my current variables to decimal type by changing that line to <code>current=decimal(current)</code> but I get <code>decimal.InvalidOperation: Invalid literal for Decimal: '51,52,52....</code> </p>
  
  <p>Any advice on how I can convert my <code>current</code> values to <code>int</code>/<code>float</code>/<code>decimal</code> type?</p>
  
  <p><strong>Updates</strong>: There is no need to go through the conversion steps for the current variable. Apparently, just using the integer list with pandas plotting is sufficient to get a plot.</p>