how to fix TypeError: format requires a mapping

hinaimran.mehr at hinaimran.mehr at
Wed Jul 1 23:57:14 CEST 2015

I am pulling my hair with this problem right now,

I have the following Data structure 

    [<OldSample {u'counter_name': u'cpu_util', u'user_id': u'id', u'resource_id': u'id', u'timestamp': u'2015-06-30T15:53:55', u'counter_volume': 0.043}]

I need to make it something like this to put in EON pubnub charting libaray (see link:

    message: {
          columns: [
            ["y": 0.043, "x": "2015-06-30T15:53:55"],
            ["y": 0.045, "x": "2015-06-30T15:53:55"]

Now I have the following code 

    data = cclient.samples.list(meter_name ='cpu_util', limit=2)

result_rows = []
for row in data:
     formatted = """["y": %(counter_volume)0.3f, "x": "%(timestamp)s"]""" % (row)


More information about the Python-list mailing list