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]
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]
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]
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]