« first day (2208 days earlier)      last day (1133 days later) » 

6:04 PM
Need some advice:

lets say I have a dataframe:
df = pd.DataFrame(np.random.randint(0,100,(5,5)),
columns=pd.MultiIndex.from_arrays((list('abcde'),list('defgh'))),
index=pd.MultiIndex.from_arrays((list('abdfe'),list('somet'))))
print(df)

I am trying to return an Boolean array based on the condition that the level=0 of index equals level=0 of level=0 of columns.

something like :

cond = (df.index.get_level_values(0).to_numpy()[:,None]
== df.columns.get_level_values(0).to_numpy())
print(cond)

wanted to know if there is a better option
 
... enjoying the formatting show <grabs popcorn> :P
1 message moved from Python
1 message moved from Python
 

« first day (2208 days earlier)      last day (1133 days later) »