I am struggling with the basic task of constructing a DataFrame of counts by value from a tuple produced by
np.unique(arr, return_counts=True)
import numpy as np
import pandas as pd
np.random.seed(123)
birds=np.random.choice(['African Swallow','Dead Parrot','Exploding Penguin'], size=int(5e4))
someTuple=np.unique(birds, return_counts = True)
someTuple
#(array(['African Swallow', 'Dead Parrot', 'Exploding Penguin'],
# dtype='<U17'), array([16510, 16570, 16920], dtype=int64))
pd.DataFrame(list(someTuple))
# Returns this:
# 0 1 2
# 0 African Swallow Dead Parrot Exploding Penguin
# 1 16510 16570 16920
pd.DataFrame.from_records(someTuple)
# birdType birdCount
# 0 African Swallow 16510
# 1 Dead Parrot 16570
# 2 Exploding Penguin 16920
Here's one NumPy based solution with np.column_stack

pd.DataFrame(np.column_stack(someTuple),columns=['birdType','birdCount'])
Or with np.vstack

pd.DataFrame(np.vstack(someTuple).T,columns=['birdType','birdCount'])
Benchmarking np.transpose
, np.column_stack
and np.vstack
for staking 1D
arrays into columns to form a 2D
array 
In [54]: tup1 = (np.random.rand(1000),np.random.rand(1000))
In [55]: %timeit np.transpose(tup1)
100000 loops, best of 3: 15.9 µs per loop
In [56]: %timeit np.column_stack(tup1)
100000 loops, best of 3: 11 µs per loop
In [57]: %timeit np.vstack(tup1).T
100000 loops, best of 3: 14.1 µs per loop