Transpose an Attribute Table with Multi-Level Index

241
2
04-13-2020 09:51 AM
deleted-user-PUOLzzPmi8Uz
New Contributor

Hi there. I am trying to take a feature class attribute table with n columns and rearrange its table structure so I can use it as a "Many" table in a relationship class, but I am struggling on how to transpose the table in arcpy and preserve two index columns, in this example, OBJECTID and ObjectType and export it as a .dbf. I was thinking pandas could do this, but my attempts to implement it has failed so far. Appreciate any help! Thanks.

The attribute table is a typical feature class structure and looks like this:

OBJECTIDObjectTypeAtrr2Attr3Attr4Attr5n….
1Red162Yes….
2Green433No….
3Blue325Yes….

What I need is the attribute structured like this:

OBJECTIDObjectTypeAttributeValue
1RedAtrr21
1RedAttr36
1RedAttr42
1RedAttr5Yes
2GreenAtrr24
2GreenAttr33
2GreenAttr43
2GreenAttr5No
3BlueAtrr23
3BlueAttr32
3BlueAttr45
3BlueAttr5Yes
0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

how do you get 4 Red 's etc.  Is it simply the number of Attr columns?

You would be better of doing this in numpy, pandas or even excel,

Pro lacks easy row replication and translation tools

0 Kudos
deleted-user-PUOLzzPmi8Uz
New Contributor

Hi Dan. Yes, its simply number of Attr columns. Just realized the table did add up. All fixed. Yeah, looks like an Excel Macro is the way to go. Thanks, Jason.

0 Kudos