@@ -47,14 +47,23 @@ def main():
4747 print ("1. Create records from a DataFrame" )
4848 print ("-" * 60 )
4949
50- new_accounts = pd .DataFrame ([
51- {"name" : f"Contoso_{ tag } " , "telephone1" : "555-0100" , "websiteurl" : "https://contoso.com" ,
52- "lastonholdtime" : pd .Timestamp ("2024-06-15 10:30:00" )},
53- {"name" : f"Fabrikam_{ tag } " , "telephone1" : "555-0200" , "websiteurl" : None ,
54- "lastonholdtime" : None },
55- {"name" : f"Northwind_{ tag } " , "telephone1" : None , "websiteurl" : "https://northwind.com" ,
56- "lastonholdtime" : pd .Timestamp ("2024-12-01 08:00:00" )},
57- ])
50+ new_accounts = pd .DataFrame (
51+ [
52+ {
53+ "name" : f"Contoso_{ tag } " ,
54+ "telephone1" : "555-0100" ,
55+ "websiteurl" : "https://contoso.com" ,
56+ "lastonholdtime" : pd .Timestamp ("2024-06-15 10:30:00" ),
57+ },
58+ {"name" : f"Fabrikam_{ tag } " , "telephone1" : "555-0200" , "websiteurl" : None , "lastonholdtime" : None },
59+ {
60+ "name" : f"Northwind_{ tag } " ,
61+ "telephone1" : None ,
62+ "websiteurl" : "https://northwind.com" ,
63+ "lastonholdtime" : pd .Timestamp ("2024-12-01 08:00:00" ),
64+ },
65+ ]
66+ )
5867 print (f" Input DataFrame:\n { new_accounts .to_string (index = False )} \n " )
5968
6069 # create_dataframe returns a Series of GUIDs aligned with the input rows
@@ -126,9 +135,11 @@ def main():
126135
127136 # Default: NaN/None fields are skipped (not overridden on server)
128137 print ("\n Updating with NaN values (default: clear_nulls=False, fields should stay unchanged)..." )
129- sparse_df = pd .DataFrame ([
130- {"accountid" : new_accounts ["accountid" ].iloc [0 ], "telephone1" : "555-9999" , "websiteurl" : None },
131- ])
138+ sparse_df = pd .DataFrame (
139+ [
140+ {"accountid" : new_accounts ["accountid" ].iloc [0 ], "telephone1" : "555-9999" , "websiteurl" : None },
141+ ]
142+ )
132143 client .update_dataframe (table , sparse_df , id_column = "accountid" )
133144 verified = next (client .get_dataframe (table , select = select_cols , filter = test_filter ))
134145 print (f" Verified (Contoso telephone1 updated, websiteurl unchanged):\n { verified .to_string (index = False )} " )
0 commit comments