Playa

Python solution to convert single column into multiple columns

Discussion created by Playa on Mar 30, 2016
Latest reply on Mar 30, 2016 by Dan_Patterson

I have generated a summary statistics table based on service area analysis areas (5 min, 10 min, 15min etc) for each settlement area that I'm determining travel times from individual buildings within a settlement to a social facilities (i.e. Clinics, Schools etc)

My output from my summary statistics table has the following columns:

 

  • TOWN = Town Name
  • SETTLEMENTNAME = Settlement Name
  • NAME = Social Facility Name (i.e. School Name or Health Care Name)
  • TIME = Service Area Time Interval ( 5 min, 10 min, 15min - 60 min)
  • COUNT_NAME = The number of buildings within each service area (5 min, 10 min - 60 min)

 

I'd like to convert the following Summary Statistics results table into the following format:

 

  • TOWN
  • SETTLEMENTNAME
  • NAME
  • 0 - 5 MIN  = The number of buildings within 0 - 5 min of the Social Facility
  • 5 - 10 MIN  = The number of buildings within 5 - 10 min of the Social Facility
  • 10 - 15 MIN  = The number of buildings within 10 - 15 min of the Social Facility
  • 15 - 20 MIN  = The number of buildings within 15 - 20 min of the Social Facility
  • 20 - 25 MIN  = The number of buildings within 20 - 25 min of the Social Facility
  • 25 - 30 MIN  = The number of buildings within 25 - 30 min of the Social Facility
  • 30 - 60 MIN  = The number of buildings within 30- 60 min of the Social Facility

 

I've attached a print screen of the Summary Statistics Table as well as the Output Results Table that I'm trying to achieve.

 

I've briefly read that either Numpy or Pandas would be able to achieve the results that I'm looking for, but I'm a novice with Numpy and have never used Pandas. Any help would be appreciated.

Outcomes