ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 23 Aug 2020 22:54:47 +0200Pandas in Sage : how to remove elements when the name of the column has white spaces inside it.https://ask.sagemath.org/question/53142/pandas-in-sage-how-to-remove-elements-when-the-name-of-the-column-has-white-spaces-inside-it/ I am using Pandas from Sage and I have a stupid problem. I have a data bases whose column titles incorporate some "space characters" like `Sortie de Chais 2019`. Unfortunately, there is also a column untitled `Sortie de Chais 2018` so I cannot use only `Sortie` as the name of the column. So a command like
df = df[df.Sortie de Chais 2019 != 0]
could not do the job. Of course if the name was `Sortie_de_Chais_2019`, the problem would disapear. But I cannot change the titles of the data base directly. I know the number of the column (in this case 26). So how can I manage my problem ?
Thanks for help
Sun, 23 Aug 2020 20:27:05 +0200https://ask.sagemath.org/question/53142/pandas-in-sage-how-to-remove-elements-when-the-name-of-the-column-has-white-spaces-inside-it/Answer by Cyrille for <p>I am using Pandas from Sage and I have a stupid problem. I have a data bases whose column titles incorporate some "space characters" like <code>Sortie de Chais 2019</code>. Unfortunately, there is also a column untitled <code>Sortie de Chais 2018</code> so I cannot use only <code>Sortie</code> as the name of the column. So a command like</p>
<pre><code>df = df[df.Sortie de Chais 2019 != 0]
</code></pre>
<p>could not do the job. Of course if the name was <code>Sortie_de_Chais_2019</code>, the problem would disapear. But I cannot change the titles of the data base directly. I know the number of the column (in this case 26). So how can I manage my problem ?</p>
<p>Thanks for help</p>
https://ask.sagemath.org/question/53142/pandas-in-sage-how-to-remove-elements-when-the-name-of-the-column-has-white-spaces-inside-it/?answer=53146#post-id-53146The following URL `https://medium.com/@chaimgluck1/working-with-pandas-fixing-messy-column-names-42a54a6659cd` gives the answer.
Sun, 23 Aug 2020 22:54:47 +0200https://ask.sagemath.org/question/53142/pandas-in-sage-how-to-remove-elements-when-the-name-of-the-column-has-white-spaces-inside-it/?answer=53146#post-id-53146