Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    convert datas[0] into a pandas DataFrame

    Indicators/Strategies/Analyzers
    2
    2
    1019
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dongiulio last edited by

      Re: Using backtrader data to make a Pandas dataframe from

      I have a similar issue, I'm creating a new indicator and I find it would be really useful to have the datas[0] (or to be able to convert it) as a pandas dataframe.

      There is a quantity of packages available in python to do advanced math using dataframes, additionally handling dataframes is so much easier and common practice that it just makes sense to have a as_dataframe method to get a pandas representation of it.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        One of goals of backtrader was to not rely on libraries which are not part of the standard Python distribution, no matter how many million users it may have.

        Adding a as_dataframe method would break that goal. Furthermore, understanding your point, you have to consider that the internal representation of the lines is not a table-like structure (like it is the case for a dataframe).

        You can slice, so to say, with the get method of a line and pass the resulting array to the dataframe constructor.

        See: Docs - Platform Concepts - Section: Slicing

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors