class_docstr: Base data class containing some data to be queried.
  Can contain text snippets, tables, and file paths to images or audios.
  Documents can be sorted by score and saved to/from dictionary and JSON.
  
  :param id: Unique identifier for the document. When not set, it's generated based on the Document fields' values.
  :param content: Text of the document, if the document contains text.
  :param dataframe: Pandas dataframe with the document's content, if the document contains tabular data.
  :param blob: Binary data associated with the document, if the document has any binary data associated with it.
  :param meta: Additional custom metadata for the document. Must be JSON-serializable.
  :param score: Score of the document. Used for ranking, usually assigned by retrievers.
  :param embedding: Vector representation of the document.
class_docstr_tok: ["Base","data","class","containing","some","data","to","be","queried",".","Can","contain","text","snippets",",","tables",",","and","file","paths","to","images","or","audios",".","Documents","can","be","sorted","by","score","and","saved","to\/from","dictionary","and","JSON",".",":","param","id",":","Unique","identifier","for","the","document",".","When","not","set",",","it","'s","generated","based","on","the","Document","fields","'","values",".",":","param","content",":","Text","of","the","document",",","if","the","document","contains","text",".",":","param","dataframe",":","Pandas","dataframe","with","the","document","'s","content",",","if","the","document","contains","tabular","data",".",":","param","blob",":","Binary","data","associated","with","the","document",",","if","the","document","has","any","binary","data","associated","with","it",".",":","param","meta",":","Additional","custom","metadata","for","the","document",".","Must","be","JSON-serializable",".",":","param","score",":","Score","of","the","document",".","Used","for","ranking",",","usually","assigned","by","retrievers",".",":","param","embedding",":","Vector","representation","of","the","document","."]
docstr: Creates a new Document object from a dictionary.
  `dataframe` and `blob` fields are converted to their original types.
docstr_tok: ["Creates","a","new","Document","object","from","a","dictionary",".","`","dataframe","`","and","`","blob","`","fields","are","converted","to","their","original","types","."]
code: def from_dict(cls, data: Dict[str, Any]) -> "Document":
      """
      Creates a new Document object from a dictionary.
      `dataframe` and `blob` fields are converted to their original types.
      """
      if (dataframe := data.get("dataframe")) is not None:
          data["dataframe"] = pandas.read_json(io.StringIO(dataframe))
      if blob := data.get("blob"):
          data["blob"] = ByteStream(
              data=bytes(blob["data"]), mime_type=blob["mime_type"]
          )
      # Store metadata for a moment while we try un-flattening allegedly flatten metadata.
      # We don't expect both a `meta=` keyword and flatten metadata keys so we'll raise a
      # ValueError later if this is the case.
      meta = data.pop("meta", {})
      # Unflatten metadata if it was flattened. We assume any keyword argument that's not
      # a document field is a metadata key. We treat legacy fields as document fields
      # for backward compatibility.
      flatten_meta = {}
      legacy_fields = ["content_type", "id_hash_keys"]
      document_fields = legacy_fields + [f.name for f in fields(cls)]
      for key in list(data.keys()):
          if key not in document_fields:
              flatten_meta[key] = data.pop(key)
  
      # We don't support passing both flatten keys and the `meta` keyword parameter
      if meta and flatten_meta:
          raise ValueError(
              "You can pass either the 'meta' parameter or flattened metadata keys as keyword arguments, "
              "but currently you're passing both. Pass either the 'meta' parameter or flattened metadata keys."
          )
  
      # Finally put back all the metadata
      return cls(**data, meta={**meta, **flatten_meta})
  
file_path: haystack/haystack/dataclasses/document.py
imports: import io
  import hashlib
  import logging
  from dataclasses import asdict, dataclass, field, fields
  from typing import Any, Dict, List, Optional
  import numpy
  import pandas
  from haystack.dataclasses.byte_stream import ByteStream
label_desc: Use image node_id 6 for calling the Document obj's underlying member method code with example usage: obj.from_dict(cls, data) and returns: cls