Guest User

Untitled

a guest
Feb 13th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. Overwrite=No,,"* Changing the setting to ?Overwrite=Yes? will have the added effect of deactivating all of your items from the website except for those listed on this datafeed. If this is not intended, keep ?Overwrite=No?.",,,,,,,,
  2. Part #,Item #,Currency,MSRP,MAP,Checkout MAP,Selling Price,Inventory,Fulfillment Option,Shipping,Activation Mark
  3. PS2-BEC-5780,9SIAFDG6V86915,USD,,0.00,False,26.98,37,Seller,free,True
  4.  
  5. Overwrite = Yes,,* Changing the setting to ?Overwrite=Yes? will have the added effect of deactivating all of your items from the website except for those listed on this datafeed. If this is not intended, keep ?Overwrite=No?.
  6. Part #,Item #,Currency,MSRP,MAP,Checkout MAP,Selling Price,Inventory,Fulfillment Option,Shipping,Activation Mark
  7. PS2-BEC-5780,,USD,,0.00,False,26.98,37,Seller,free,True
  8.  
  9. import pandas as pd
  10.  
  11. d1 = pd.read_csv(filename1, skiprows=1, usecols=['Part #','Item #'])
  12. d2 = pd.read_csv(filename2, skiprows=1).drop('Item #',axis=1)
  13.  
  14. res = d2.merge(d1, on='Part #', how='left')
  15.  
  16. d1 = pd.read_csv(filename1, skiprows=1, usecols=['Part #','Item #'])
  17. d2 = pd.read_csv(filename2, skiprows=1)
  18.  
  19. d2['Item #'] = d2['Part #'].map(d1.set_index('Part #')['Item #'])
  20.  
  21. In [106]: d2['Item #'] = d2['Part #'].map(d1.set_index('Part #')['Item #'])
  22.  
  23. In [107]: d2
  24. Out[107]:
  25. Part # Item # Currency MSRP MAP Checkout MAP Selling Price Inventory Fulfillment Option Shipping
  26. 0 PS2-BEC-5780 9SIAFDG6V86915 USD NaN 0.0 False 26.98 37 Seller free
  27.  
  28. Activation Mark
  29. 0 True
  30.  
  31. d2.to_csv(r'/path/to/file.csv', index=False)
  32.  
  33. #!/usr/bin/env python3
  34. import pandas as pd
  35.  
  36. # use unique keys as index
  37. df = pd.read_csv('1.csv', index_col=0, names=['key', 'value'], header=None)
  38. print(df)
  39.  
  40. # read as series
  41. keys = pd.read_csv('2.csv', squeeze=True, names=['key'])
  42. print('nKeys:', *keys)
  43. print('n', df.loc[keys])
  44.  
  45. value
  46. key
  47. a 1
  48. b 2
  49. c 3
  50. d 4
  51.  
  52. Keys: b d b
  53.  
  54. value
  55. key
  56. b 2
  57. d 4
  58. b 2
Add Comment
Please, Sign In to add comment