-4
I need some help, I’m getting laid. I have the title as shown in the table on the left and need to transform with Pandas in the format of the table in yellow, will the account Pandas?
I am with 3 columns and more than 1000 rows. There are randomly rows that have information different from all the others. In those in question, has in the first column all the same value, see below that whole line:
col1 col2 col3
-------------------------------------------------
FIG. Item Nomes diferentes nesta coluna
In all these rows you have the column with the value "FIG."; that is, what differentiates these lines from the others.
I need to filter these lines (with "FIG.") and take the value of this line which is a text that is in the third column and create a fourth column with that value. Can you help me with that? It would look something like this:
col1 col2 col3 col4
------------------------------------------------------------------------------------
FIG. Item Nomes diferentes nesta coluna Nomes diferentes nesta coluna
After that I want to go back to DataFrame
which contains all lines before filtering but which stays with this fourth column.
I did that and the filter worked:
df_mask = df['FIG.'] =='FIG.' filtered_df = df[df_mask] lista = filtered_df
And that worked, too:
df = pd.DataFrame(lista,columns=['FIG.','Item','Nomes diferentes nesta coluna'])
But I’m unable to create a new column with the values "Different names in this column".
Luiz, the description is a little confusing to understand. You could update your post by placing 3 lines of your original dataframe and the output you expect?
– Paulo Marques
Luiz Notari, don’t tear up the questions.
– Augusto Vasques