How to convert python data for use in rHow to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?

I reverse the source code, you reverse the input!

My Project Manager does not accept carry-over in Scrum, Is that normal?

New road bike: alloy dual pivot brakes work poorly

Character Transformation

Which lens has the same capability of lens mounted in Nikon P1000?

Why does my browser attempt to download pages from http://clhs.lisp.se instead of viewing them normally?

Why does this image of Jupiter look so strange?

What is the difference between an astronaut in the ISS and a freediver in perfect neutral buoyancy?

Diminutive -ula

Algorithm that generates orthogonal vectors: C++ implementation

Whaling ship logistics

A famous scholar sent me an unpublished draft of hers. Then she died. I think her work should be published. What should I do?

Difference between types of yeast

Why is 6. Nge2 better, and 7. d5 a necessary push in this game?

Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?

What does it mean by "my days-of-the-week underwear only go to Thursday" in this context?

Beyond Futuristic Technology for an Alien Warship?

Why does the leading tone (G#) go to E rather than A in this example?

GP conform to mesh

Why are there two fundamental laws of logic?

What secular civic space would pioneers build for small frontier towns?

Is it acceptable to say that a reviewer's concern is not going to be addressed because then the paper would be too long?

Duplicate Tuples in two different ways

Would you write key signatures for non-conventional scales?



How to convert python data for use in r


How to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















With the reticulate library, I'm using Python to gather market data and account positions for my r script. While most datasets convert cleanly between the 2 languages, I'm stuck on this particular dataset. How do I convert this particular dataset into an r data structure, preferably a data frame?



Here's my python code:



import pickle
import io
def getPythonData():
with open('OpenPositions.dump','rb') as f:
data = pickle.load(f)
return (data)


Here's my r code:



library(reticulate)
use_python("/usr/local/bin/python3.7")
source_python("PyGetData.py")
data <- getPythonData()
print (data)
class(data)
class(data[[1]])
x <- data.frame(py_to_r(data))
x <- data.frame(py_to_r(data[[1]]))


Here's the output from the print (data) command, which is a list with 2 elements:



[[1]]
Position(account='DU1340125', contract=Future(conId=138979241, symbol='CL', lastTradeDateOrContractMonth='20190422', multiplier='1000', currency='USD', localSymbol='CLK9', tradingClass='CL'), position=1.0, avgCost=59832.37)

[[2]]
Position(account='DU1340125', contract=Future(conId=321454633, symbol='YM', lastTradeDateOrContractMonth='20190621', multiplier='5', currency='USD', localSymbol='YM JUN 19', tradingClass='YM'), position=1.0, avgCost=128087.05)









share|improve this question
































    0















    With the reticulate library, I'm using Python to gather market data and account positions for my r script. While most datasets convert cleanly between the 2 languages, I'm stuck on this particular dataset. How do I convert this particular dataset into an r data structure, preferably a data frame?



    Here's my python code:



    import pickle
    import io
    def getPythonData():
    with open('OpenPositions.dump','rb') as f:
    data = pickle.load(f)
    return (data)


    Here's my r code:



    library(reticulate)
    use_python("/usr/local/bin/python3.7")
    source_python("PyGetData.py")
    data <- getPythonData()
    print (data)
    class(data)
    class(data[[1]])
    x <- data.frame(py_to_r(data))
    x <- data.frame(py_to_r(data[[1]]))


    Here's the output from the print (data) command, which is a list with 2 elements:



    [[1]]
    Position(account='DU1340125', contract=Future(conId=138979241, symbol='CL', lastTradeDateOrContractMonth='20190422', multiplier='1000', currency='USD', localSymbol='CLK9', tradingClass='CL'), position=1.0, avgCost=59832.37)

    [[2]]
    Position(account='DU1340125', contract=Future(conId=321454633, symbol='YM', lastTradeDateOrContractMonth='20190621', multiplier='5', currency='USD', localSymbol='YM JUN 19', tradingClass='YM'), position=1.0, avgCost=128087.05)









    share|improve this question




























      0












      0








      0








      With the reticulate library, I'm using Python to gather market data and account positions for my r script. While most datasets convert cleanly between the 2 languages, I'm stuck on this particular dataset. How do I convert this particular dataset into an r data structure, preferably a data frame?



      Here's my python code:



      import pickle
      import io
      def getPythonData():
      with open('OpenPositions.dump','rb') as f:
      data = pickle.load(f)
      return (data)


      Here's my r code:



      library(reticulate)
      use_python("/usr/local/bin/python3.7")
      source_python("PyGetData.py")
      data <- getPythonData()
      print (data)
      class(data)
      class(data[[1]])
      x <- data.frame(py_to_r(data))
      x <- data.frame(py_to_r(data[[1]]))


      Here's the output from the print (data) command, which is a list with 2 elements:



      [[1]]
      Position(account='DU1340125', contract=Future(conId=138979241, symbol='CL', lastTradeDateOrContractMonth='20190422', multiplier='1000', currency='USD', localSymbol='CLK9', tradingClass='CL'), position=1.0, avgCost=59832.37)

      [[2]]
      Position(account='DU1340125', contract=Future(conId=321454633, symbol='YM', lastTradeDateOrContractMonth='20190621', multiplier='5', currency='USD', localSymbol='YM JUN 19', tradingClass='YM'), position=1.0, avgCost=128087.05)









      share|improve this question
















      With the reticulate library, I'm using Python to gather market data and account positions for my r script. While most datasets convert cleanly between the 2 languages, I'm stuck on this particular dataset. How do I convert this particular dataset into an r data structure, preferably a data frame?



      Here's my python code:



      import pickle
      import io
      def getPythonData():
      with open('OpenPositions.dump','rb') as f:
      data = pickle.load(f)
      return (data)


      Here's my r code:



      library(reticulate)
      use_python("/usr/local/bin/python3.7")
      source_python("PyGetData.py")
      data <- getPythonData()
      print (data)
      class(data)
      class(data[[1]])
      x <- data.frame(py_to_r(data))
      x <- data.frame(py_to_r(data[[1]]))


      Here's the output from the print (data) command, which is a list with 2 elements:



      [[1]]
      Position(account='DU1340125', contract=Future(conId=138979241, symbol='CL', lastTradeDateOrContractMonth='20190422', multiplier='1000', currency='USD', localSymbol='CLK9', tradingClass='CL'), position=1.0, avgCost=59832.37)

      [[2]]
      Position(account='DU1340125', contract=Future(conId=321454633, symbol='YM', lastTradeDateOrContractMonth='20190621', multiplier='5', currency='USD', localSymbol='YM JUN 19', tradingClass='YM'), position=1.0, avgCost=128087.05)






      python r reticulate






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 20:03









      dubbbdan

      1,27310 silver badges24 bronze badges




      1,27310 silver badges24 bronze badges










      asked Mar 28 at 18:38









      S NovogoratzS Novogoratz

      136 bronze badges




      136 bronze badges

























          0






          active

          oldest

          votes














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404734%2fhow-to-convert-python-data-for-use-in-r%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404734%2fhow-to-convert-python-data-for-use-in-r%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript