1

I have a named tuple called "rows" if I print it, it would look as shown below. How do I efficiently (not in for loop) insert this into a pandas data frame so that I can use it to plot graphs. (Number of rows and columns can go more than a thousand sometimes)

for row in rows:
    print (row[0], row[1])  

Output:

2016-01-04    00:00:00.000000000
2016-01-04    00:01:00.000000000
2016-01-04    00:02:00.000000000
2016-01-04    00:03:00.000000000
2016-01-04    00:04:00.000000000
2016-01-04    00:05:00.000000000
reddi hari
  • 173
  • 1
  • 12

2 Answers2

1

The loop is long two steps only independently of the length of rows:

pd.DataFrame([i for i in zip(*rows)])
jimifiki
  • 5,377
  • 2
  • 34
  • 60
1

Why not just try:

df = pd.DataFrame(rows)
U13-Forward
  • 69,221
  • 14
  • 89
  • 114