How to create new header in data that has no header

Viewed 29

I'm trying to create a new columns on headerless data and want to find a workable solution.

This is the data I'm working with - it is public.

    {A42E2F04-2538-4A25-94C5-49E29C6C8FA8}  18500   1995-01-31 00:00    TQ1 1RY F   N   L   VILLA PARADISO  FLAT 10 HIGHER WARBERRY ROAD    TORQUAY TORQUAY.1   TORBAY  TORBAY.1    A   A.1
0   {1BA349E3-2579-40D6-999E-49E2A25D2284}  73450   1995-10-09 00:00    L26 7XJ D   Y   F   6   NaN CATKIN ROAD LIVERPOOL   LIVERPOOL   KNOWSLEY    MERSEYSIDE  A   A
1   {E5B50DCB-BC7A-4E54-B167-49E2A6B4148B}  59000   1995-03-31 00:00    BH12 2AE    D   N   F   28  NaN ALDER ROAD  POOLE   POOLE   POOLE   POOLE   A   A
2   {81E50116-D675-4B7F-9F8D-49E2B5D43271}  31000   1995-12-04 00:00    IP13 0DR    D   Y   F   NONSUCH COTTAGE NaN THE STREET  HACHESTON   WOODBRIDGE  SUFFOLK COASTAL SUFFOLK A   A
3   {B97455B9-75CB-40BB-A615-42C53683E143}  95000   1995-09-22 00:00    WS14 0BE    D   N   F   FOX COVER COTTAGE   NaN HALL LANE   LICHFIELD   LICHFIELD   LICHFIELD   STAFFORDSHIRE   A   A
4   {F0D1E8DA-C00D-467A-A41C-42C5378DB6E0}  45450   1995-02-28 00:00    S42 5GA S   Y   F   109 NaN ELVASTON ROAD   NORTH WINGFIELD CHESTERFIELD    NORTH EAST DERBYSHIRE   DERBYSHIRE  A   A

It has no header.

I've built one thus:

    columns = ["Transaction id", "Price", "Date of Transfer", "Postcode","Property Type",
    "PAON", "SAON", "Street", "Locality", "Town/City", "District", "County",
           "PPD Category Type"]
s = pd.DataFrame(columns).T
s

0   1   2   3   4   5   6   7   8   9   10  11  12
0   Transaction id  Price   Date of Transfer    Postcode    Property Type   PAON    SAON    Street  Locality    Town/City   District    County  PPD Category Type

I thought I could concat the two datasets, which I have done, but can't work out how to switch column data to top of dataframe without losing the current columns index which is actually data.

My code to combine the two frames:

pd.concat([s, df_price_paid.head()], axis=1)

Results in:

    0   1   2   3   4   5   6   7   8   9   ... L   VILLA PARADISO  FLAT 10 HIGHER WARBERRY ROAD    TORQUAY TORQUAY.1   TORBAY  TORBAY.1    A   A.1
0   Transaction id  Price   Date of Transfer    Postcode    Property Type   PAON    SAON    Street  Locality    Town/City   ... F   6   NaN CATKIN ROAD LIVERPOOL   LIVERPOOL   KNOWSLEY    MERSEYSIDE  A   A
1   NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... F   28  NaN ALDER ROAD  POOLE   POOLE   POOLE   POOLE   A   A
2   NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... F   NONSUCH COTTAGE NaN THE STREET  HACHESTON   WOODBRIDGE  SUFFOLK COASTAL SUFFOLK A   A
3   NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... F   FOX COVER COTTAGE   NaN HALL LANE   LICHFIELD   LICHFIELD   LICHFIELD   STAFFORDSHIRE   A   A
4   NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... F   109 NaN ELVASTON ROAD

What do I do?

0 Answers
Related