What are the all arguments for dcc.send_data_frame()

Hi all,

The documentation for dcc.Download provides some examples. There, I saw this “return dcc.send_data_frame(df.to_excel, “mydf.xlsx”, sheet_name=“Sheet_name_1”)”. My question: Where do I find info about the all arguments that can go with dcc.send_data_frame()? I didn’t find anything in the documentation.

Thanks in advance!

You can find this information in the doc string,

...
def send_data_frame(writer, filename, type=None, **kwargs):
    """
    Convert data frame into the format expected by the Download component.
    :param writer: a data frame writer
    :param filename: the name of the file
    :param type: type of the file (optional, passed to Blob in the javascript layer)
    :return: dict of data frame content (base64 encoded) and meta data used by the Download component
...

Any argument(s) beyond what is mentioned here are routed directly to the writer. Hence, in your example sheet_name will be passed to the to_excel function when it is called.

3 Likes

So, in other words, the documentation doesn’t show all the info for the function. Thus, I also need to check the doc strings to better understand the functions. Agree?

I also had some issues debugging this function, so I’ll post my learning here.

The ‘writer’ parameter was not obvious to me. It requires something like pandas.Dataframe(data).to_csv but NOT pandas.Dataframe(data).to_csv() or .to_csv(args). Including the round brackets (ie send the function not a ‘writer’) will cause the error

name = writer.__name__
AttributeError: 'str' object has no attribute '__name__'. Did you mean: '__ne__'?

The above question assisted me as it demonstrates how to send arguments such as index = False , which including in the function call led to the error above.