Let's say I have a dataframe with column names as follows:
col_id_1, col_id_2, ..., col_id_m, property_1, property_2 ..., property_n
As an example, how would I search across all col_id
s for, say, the value 5
(note that 5
won't appear in multiple col_id
s in the same row), and then choose all rows that contain this value? On top of that, once I've found all rows that have a col_id
containing the value 5
, I'll combine all the col_id
s with value 5
into a single id
column, and also only choose, say, property_8
and property_25000
as additional columns.
In this case, I would have a table with the following columns:
id, property_8, property_25000
where the id
column only contains rows with value 5
. Is such a thing possible in pandas?