Code Monkey home page Code Monkey logo

open-recipe-data's People

Contributors

jakevdp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

open-recipe-data's Issues

Some slight changes to code for those running > Py 3.8

Dear all

I am learning from the Data Science Handbook now on Py 3.8/3.9. Just to share some small lines of code/modification that needs to be included to read the json file properly in those Python versions.

a) pg185 In[19] needs importing of StringIO for use with pd.read_json() to avoid "ValueError: Protocol not known":


from io import StringIO

with open("recipeitems.json") as f:
  line = f.readline()
pd.read_json(StringIO(line)).shape


b) pg185 In[20] needs specification of encoding="utf8" to avoid a UnicodeDecodeError,
and as above, the use of StringIO() with pd.read_json():


with open("recipeitems.json", 'r', encoding="utf8") as f:
  data = (line.strip() for line in f)
  data_json = f'[{",".join(data)}]'

recipes = pd.read_json(StringIO(data_json))

recipes.shape


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.