Python Forum
How to concatenate elements of different type in a table cell?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to concatenate elements of different type in a table cell?
#1
Hi guys,

I wrote a code to print some tables, and to do that I used the following lines of code to fill my cells with the values of my array p:
for row in range(prism):
   cell_text.append(['%d' % item for item in p[row,0:4]])
That works ok. But now I have a list data_prec of values which represents the precision of the values of the array p.
So, in the position 0,0 from data_prec I have the precision for the value of p on the position 0,0. I mean, for the value 1 in the array p, the precision is 0.01 as you can see in the following example:
Output:
Array p: [1, 2, 3, 4] List data_prec: [array([0.01, 0.02, 0.05, 0.02])]
So I need to fill the cells of my tables with an element of p and its correspondent precision, I mean something like 1 +- 0.01.
I tried to modify the code above but doesn't worked. Here's my attempt:
for row in range(prism):
   cell_text.append(['%d +- %d' % item for item in p[row,0:4], % elem for elem in data_prec[row,0:4]])
I appreciate if anyone can help me. Thanks !!
Reply


Messages In This Thread
How to concatenate elements of different type in a table cell? - by Felipe - Jul-06-2017, 02:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concatenate 3D arrays paul18fr 1 2,671 Apr-09-2021, 02:49 PM
Last Post: paul18fr
  Formula with elements of list - If-condition regarding the lists elements lewielewis 2 2,751 May-08-2020, 01:41 PM
Last Post: nnk
  How to prepare a NumPy array which include float type array elements subhash 0 1,927 Mar-02-2020, 06:46 AM
Last Post: subhash
  concatenate mcgrim 1 2,257 Mar-22-2019, 01:31 PM
Last Post: buran
  Checking the elements of a matrix with an elements of a list juniorcoder 11 5,924 Sep-17-2018, 03:02 PM
Last Post: gruntfutuk
  Slicing String cell by cell Vigneshkumarsakthivel 0 2,412 Sep-02-2018, 05:59 PM
Last Post: Vigneshkumarsakthivel
  Concatenate Specific Cell Interval With Pandas vidividi12 0 2,853 Oct-01-2017, 02:16 PM
Last Post: vidividi12
  How can i convert a string to an array with elements type float 64 zoya2385 3 6,152 May-11-2017, 03:57 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020