Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19113

How to transform a table with rows containing counts into a table of containing binary values and rows equaling the total count in Postgres or R

$
0
0

I have a table in Postgres with each row a location and 19 columns containing employment counts in different industries. I would like to convert this table structure into one that represents each row as an employee and a boolean value (0/1) in each of the 19 industry columns indicating whether the employee belongs to the particular industry or not. The result would be that each location would have a number of rows that equals the number of its employees, and the total number of rows in the table would equate to the total number of employees in the original table. I've provide an example below to help illustrate what I'm trying to achieve. I could also export the data to CSV and use Python, R or Excel if it would be easier to transform the table in one of those applications.

enter image description here


Viewing all articles
Browse latest Browse all 19113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>