0

So, i'm doing a looping to create some features for a dataframe, here's how it

medianas_origem_midia = []
teste_mannwhitneyu = []
alpha = 0.05
primeiro_pedido = []
volumetria = []
for i in flag_origem_midia:
    aux = df.groupby(['cpf',i]).agg({'margem_total_regime_especial_trat':sum}).reset_index() #Pegando a soma por CPF
    teste_mannwhitneyu.append(teste_medianas(aux,i))
    a = df.groupby(i).agg({'data_primeiro_pedido':min}).reset_index()
    primeiro_pedido.append(f"""Outros: {str(a.data_primeiro_pedido[0])} \
    \
    {i}: {str(a.data_primeiro_pedido[1])}""")
    a = df.groupby(i).size().reset_index(name = 'vol')
    volumetria.append(f"""Outros: {str(a.vol[0])} {i}: {str(a.vol[1])} """)
    aux = aux.groupby(i).agg({'margem_total_regime_especial_trat':np.median}).reset_index()
    medianas_origem_midia.append((aux.margem_total_regime_especial_trat[1]-aux.margem_total_regime_especial_trat[0])/aux.margem_total_regime_especial_trat[0]*100)
del aux    
d = {'Origem/Midia':flag_origem_midia,'LTV':medianas_origem_midia,'Teste de Medianas':teste_mannwhitneyu,'Data Primeiro Pedido':primeiro_pedido,'Volumetria':volumetria}
df_origem_midia = pd.DataFrame(d)

Here, primeiro_pedido list store the first purchase on each of the flags in flag_origem_midia. My issue is that, the string created in this list is too large and it looks like this:

Origem/Midia LTV Teste de Medianas Data Primeiro Pedido Volumetria
fl_direct / n/a -5.897762 Different distribution (reject H0) Outros: 2021-01-01 fl_direct / n/a: 20... Outros: 2722123 fl_direct / n/a: 864342

As you can see in the colum "Data Primeiro Pedido", there's a "..." in the end of the string, but my goal is to show the entire string. Is there a way to break the line?

I tried to put an '\n' in the middle of the string, but it didn't worked.

1 Answers1

0

Have you tried setting pandas max column width option as suggested here?

pd.set_option('display.max_colwidth', None)

it should remove the ellipsis and display the whole value for the cell.