Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

python - Error calling update on panda: Shape of passed values is (639, 4), indices imply (637, 4)

I am creating an etl process I'm attempting to join datasets from two different sources.

An id map that comes from a database and a list of data from active directory

rows with the location 'beta' have the wrong value for 'name' and need to be replaced with the value from the map. (mains have a uuid, beta a smaller number

so i created a new column 'unique_identifier' to contain the correct values. When i try to call update i get the error in the title.

id_map = pandas.read_sql_query('SELECT unique_identifier, name FROM database WHERE name IS NOT NULL', con, index_col='name')

pages = search_ldap_paginated('ou=user, dc=contoso, dc=com', '(objectClass=computer)', ['name', 'employeeID', 'description', 'location'])
 for page in pages:
        df = pandas.DataFrame(page)
        df['name'] = df['name'].str.decode('UTF-8')
        df['unique_identifier'] = df['name']
        df.loc[df['location'] == b'beta'].set_index('name').update(id_map)
        print(df)

print(id_map)

                                      unique_identifier
name
1657B44C-240F-11B2-A85C-BEA48351D0E7           16807201
2E314D56-98B2-A171-66C0-2BC5A0AB037D           16903954
BCA0A3CC-2D97-11B2-A85C-D86D99BCF2BD           16910365
FC95004C-292B-11B2-A85C-8FCF0AC7BEC0           16931624
0932434C-3385-11B2-A85C-D01C755F05DF           16941533
...                                                 ...
6865FD4C-2442-11B2-A85C-8A9D38AE683D           17637774
33AA4D56-A892-A64D-758F-9767674D6EB0           17637775
F86B4D56-C834-9A1B-18FB-96FC1BB9F9F6           17637776
2BF24D56-BFFD-4701-0E83-3A74BFF01896           17637778
3244C601-43E9-11CB-A36D-DD30357C35BB           17637780

print(pandas.DataFrame(page))

      description                                     name   employeeID location
0   b'01/11/2021'  b'F2FBE3BC-2DA8-5069-80C7-E8F89401D838'   b'foo'  b'main'
0   b'01/12/2021'  b'17192D4C-2E88-11B2-A85C-FB5D802ED60A'  b'bar'  b'main'
0   b'01/11/2021'  b'50AAC670-DE82-560E-BFF7-B8DD89C19EDE'    b'baz'  b'main'
0   b'01/12/2021'  b'0FA0F64C-3510-11B2-A85C-BA67FE61474A'   b'bat'  b'beta'
0   b'11/04/2020'  b'532A304C-343C-11B2-A85C-C8B2E65C7228'      b'bin'  b'beta'
..            ...                                      ...          ...      ...
0   b'12/22/2020'  b'CE5B5405-327D-5F1A-A649-5E700636775E'   b'boo'  b'main'
0   b'10/24/2019'  b'B5C6B7CC-312E-11B2-A85C-D63EFC125128'  b'fab'  b'beta'
0   b'01/11/2021'  b'3C8E210C-D4D5-50E3-B49D-3D29AFB6792E'     b'fim'  b'main'
0   b'01/12/2021'  b'7B5AC981-542D-11CB-B097-D37B1FED638E'  b'bam'  b'beta'
0   b'12/09/2020'  b'7E66ED80-74EC-11EA-8E41-E025FBA91800'     b'fat'  b'beta

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...