Jun-10-2019, 06:46 AM
Isn't there needless conversions in creating record_list?
>>> a = [1, 2, 3] >>> b = 'abc' >>> c = [10, 20, 30] >>> for row in zip(a, b, c): .... print(row) .... (1, 'a', 10) (2, 'b', 20) (3, 'c', 30) >>> for row in list(zip(a, b, c)): .... print(row) .... (1, 'a', 10) (2, 'b', 20) (3, 'c', 30) >>> [list(item) for item in list(zip(a, b, c))] [[1, 'a', 10], [2, 'b', 20], [3, 'c', 30]] >>> list(zip(a, b, c)) [(1, 'a', 10), (2, 'b', 20), (3, 'c', 30)]DataFrame data source can be iterable (documentation: data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame) therefore even converting to list is not necessary:
>>> df = pd.DataFrame(zip(a, b, c), columns = ('First', 'Second', 'Third')) >>> df First Second Third 0 1 a 10 1 2 b 20 2 3 c 30
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.