467,915 Members | 1,861 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

How to filter out Column data From Multiple rows data?

Bit
Good Evening


Hi everyone, so i got the following JSON file from Walmart regarding their product items and price.


so i loaded up jupyter notebook, imported pandas and then loaded it into a Data frame with custom columns as shown in the pics below.


now this is what i want to do:

make new columns named as min price and max price and load the data into it

how can i do that ?


Here is the code in jupyter notebook for reference.

i also want the offer price as some items don't have minprice and maxprice :)


EDIT: Here is the code and Json file

Json File: https://pastebin.com/sLGCFCDC

Python Code:

Expand|Select|Wrap|Line Numbers
  1. import json
  2. import pandas as pd
  3.  
  4.  
  5. with open("walmart.json") as f:
  6.     data = json.load(f)
  7.  
  8. walmart = data["items"]
  9.  
  10.  
  11. wdf = pd.DataFrame(walmart,columns=["productId","primaryOffer"])
  12.  
  13.  
  14. print(wdf.loc[0,"primaryOffer"])
  15.  
  16.  
  17. pd.set_option('display.max_colwidth', None)
  18.  
  19.  
  20. print(wdf)
Attached Images
File Type: jpg walmart1.jpg (106.4 KB, 7 views)
File Type: jpg walmart2.jpg (227.4 KB, 8 views)
4 Weeks Ago #1
  • viewed: 861
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.