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:
OBJECTID | ObjectType | Atrr2 | Attr3 | Attr4 | Attr5 | n…. |
1 | Red | 1 | 6 | 2 | Yes | …. |
2 | Green | 4 | 3 | 3 | No | …. |
3 | Blue | 3 | 2 | 5 | Yes | …. |
What I need is the attribute structured like this:
OBJECTID | ObjectType | Attribute | Value |
1 | Red | Atrr2 | 1 |
1 | Red | Attr3 | 6 |
1 | Red | Attr4 | 2 |
1 | Red | Attr5 | Yes |
2 | Green | Atrr2 | 4 |
2 | Green | Attr3 | 3 |
2 | Green | Attr4 | 3 |
2 | Green | Attr5 | No |
3 | Blue | Atrr2 | 3 |
3 | Blue | Attr3 | 2 |
3 | Blue | Attr4 | 5 |
3 | Blue | Attr5 | Yes |
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
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.