Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamlit : supprimer l'index numéroté des dataframes pandas ? #60

Open
jeremyfix opened this issue Apr 13, 2024 · 0 comments
Open

Streamlit : supprimer l'index numéroté des dataframes pandas ? #60

jeremyfix opened this issue Apr 13, 2024 · 0 comments

Comments

@jeremyfix
Copy link
Collaborator

En travaillant sur les dataframes transposées (#54) , en expérimentant avec unstructured, on a un index numéroté qui apparaît.

Cet index numéroté est embêtant parce qu'en transposant la dataframe, les noms de colonnes deviennent ces numéros.

Par exemple, sur Enel 2020 , on a un tableau :

,Unnamed: 0,UM,Italy,Spain,Russia,Romania,Unnamed: 6,Netherlands,2020,2019,2020-2019,Unnamed: 11,%,Unnamed: 13,Unnamed: 14
0,Taxes Borne (cash accounting),,17424,10599,287,,295,444,29050,29392,342,342,-12%,,
1,Profit taxes Income tax,€/mil,10254,1122,132,211,,434,9909,10676,768,768,-72%,,
2,Profit taxes Income tax,,€/mil,10254,1362,132,211,,434,9669,10369,,700,-67%,
3,Property taxes,€/mil,1299,697,56,41,,,2094,2040,,54,26%,,

et en transposant :

                                        0                        1                        2   ...                     27                                   28                                       29
Unnamed: 0   Taxes Borne (cash accounting)  Profit taxes Income tax  Profit taxes Income tax  ...  Ratio TTC to turnover  Taxes Borne in relation to revenues  Taxes Collected in relation to revenues
UM                                     NaN                    €/mil                      NaN  ...                  % fo}                                % fo}                                    % fo}
Italy                                17424                    10254                    €/mil  ...                   216%                                  41%                                     175%
Spain                                10599                     1122                    10254  ...                   166%                                  63%                                     103%

Et il suffit de faire :

df = df.set_index(df.columns[0])

et hop , on peut transposer :

                                                   UM    Italy   Spain  Russia  Romania Unnamed: 6  Netherlands     2020     2019   2020-2019 Unnamed: 11       % Unnamed: 13 Unnamed: 14
Unnamed: 0                                                                                                                                                                               
Taxes Borne (cash accounting)                     NaN    17424   10599     287      NaN        295          444    29050    29392         342         342    -12%         NaN         NaN
Profit taxes Income tax                         €/mil    10254    1122     132      211        NaN          434     9909    10676         768         768    -72%         NaN         NaN
Profit taxes Income tax                           NaN    €/mil   10254    1362      132        211          NaN      434     9669       10369         NaN     700        -67%         NaN

en

Unnamed: 0  Taxes Borne (cash accounting) Profit taxes Income tax Profit taxes Income tax  ... Ratio TTC to turnover Taxes Borne in relation to revenues Taxes Collected in relation to revenues
UM                                    NaN                   €/mil                     NaN  ...                 % fo}                               % fo}                                   % fo}
Italy                               17424                   10254                   €/mil  ...                  216%                                 41%                                    175%
Spain                               10599                    1122                   10254  ...                  166%                                 63%                                    103%

La question est de savoir si ce changement df.set_index(df.columns[0]) peut appliquer tout le temps, quel que soit l'algorithme ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant