I have a pandas dataframe looking like this:
variable value
0 company_id
1 company_name Rechner
2 former_company_name
3 company_street Teststraße
4 company_street_nr 20
5 company_name Rechner2
6 former_company_name
7 company_street Ringstraße
8 company_street_nr 20
.. ... ...
[119 rows x 2 columns]
The dataframe looks like this because it is extracted from an excel file which other people have to fill for me. I need to get all the values in my database. In order to do so I want to generate a csv file. To do this I would like to merge the rows with the same variable name and write a new column with value2. Like this:
variable value value2
0 company_id
1 company_name Rechner Rechner2
2 former_company_name
3 company_street Teststraße Ringstraße
4 company_street_nr 20 20
At the moment I'm doing this with extracting the rows by their indexes and using a join with the single dataframes. I would like to know if there is a better way to do this.