-2

I have a dataframe in the following form:

a=[(0.0,),(40.0,),(40.0,),(40.0,)]

How do I get the integral values from this data (i.e I want to get the following output):

a=[0,40,40,40]
User7598
  • 1,658
  • 1
  • 15
  • 28
  • possible duplicate of [Flattening a shallow list in Python](http://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python) – Martin Mar 26 '15 at 16:37

2 Answers2

1

Try this:

In [1]: a=[(0.0,),(40.0,),(40.0,),(40.0,)]

In [2]: b = [int(i[0]) for i in a]

In [3]: b
Out[3]: [0, 40, 40, 40]
lapinkoira
  • 8,320
  • 9
  • 51
  • 94
0

This is a simple way to achieve the objective

# for python3
a=[(0.0,),(40.0,),(40.0,),(40.0,)]

y=[]
for x in a:
  y.append(int(x[0]))

print (y)

Output

[0, 40, 40, 40]