Giter Site home page Giter Site logo

Comments (4)

natenka avatar natenka commented on June 29, 2024

This issue is not related to tabulate. You have created a set with dictionaries. The elements of a set must be immutable object: number, string, tuple.
You need to create a list or tuple of dictionaries (square brakets or parentheses), then everything will work

data = [{'IP': '15.0.15.1',
'Interface': 'FastEthernet0/0',
'Protocol': 'up',
'Status': 'up'
},
{'IP': '10.0.12.1',
'Interface': 'FastEthernet0/1',
'Protocol': 'up',
'Status': 'up'},
{'IP': '100.0.0.1',
'Interface': 'Loopback100',
'Protocol': 'up',
'Status': 'up'}]

print(tabulate(data, headers='keys'))

from pyneng-book-en.

kvaleriy avatar kvaleriy commented on June 29, 2024

Still it returns error:
Traceback (most recent call last):
File "/Users/Retina/PycharmProjects/python-start/Play.py", line 17, in
print(tabulate(data, headers='key'))
File "/Users/Retina/Library/Python/3.8/lib/python/site-packages/tabulate.py", line 1426, in tabulate
list_of_lists, headers = _normalize_tabular_data(
File "/Users/Retina/Library/Python/3.8/lib/python/site-packages/tabulate.py", line 1073, in _normalize_tabular_data
raise ValueError(
ValueError: headers for a list of dicts is not a dict or a keyword

from pyneng-book-en.

natenka avatar natenka commented on June 29, 2024

Typo in headers (keyS):

headers='keys')

Screenshot 2020-11-11 165041

from pyneng-book-en.

kvaleriy avatar kvaleriy commented on June 29, 2024

You are right, sorry for bothering with typo.

By the way your book is quit good!

from pyneng-book-en.

Related Issues (6)

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.