How to convert rpy2.robjects.vectors.DataFrame to csv?
After executing my python file i got result as:
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
...
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
len(a)=12
type(a)=rpy2.robjects.vectors.DataFrame
I am trying to convert the result dataframe to csv by a.to_csv('filename.csv')
But it wont work for the current result. Anybody have any idea about how to convert 'rpy2.robjects.vectors.DataFrame csv'
. Any help is appreciated.
python rpy2
add a comment |
After executing my python file i got result as:
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
...
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
len(a)=12
type(a)=rpy2.robjects.vectors.DataFrame
I am trying to convert the result dataframe to csv by a.to_csv('filename.csv')
But it wont work for the current result. Anybody have any idea about how to convert 'rpy2.robjects.vectors.DataFrame csv'
. Any help is appreciated.
python rpy2
add a comment |
After executing my python file i got result as:
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
...
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
len(a)=12
type(a)=rpy2.robjects.vectors.DataFrame
I am trying to convert the result dataframe to csv by a.to_csv('filename.csv')
But it wont work for the current result. Anybody have any idea about how to convert 'rpy2.robjects.vectors.DataFrame csv'
. Any help is appreciated.
python rpy2
After executing my python file i got result as:
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
...
R object with classes: ('data.frame',) mapped to:
<DataFrame - Python:0x7f3f3c05a388 / R:0x563006a79ea8>
[DataFrame, DataFrame, DataFrame, DataFrame, ..., DataFrame, DataFrame, DataFrame, DataFrame]
len(a)=12
type(a)=rpy2.robjects.vectors.DataFrame
I am trying to convert the result dataframe to csv by a.to_csv('filename.csv')
But it wont work for the current result. Anybody have any idea about how to convert 'rpy2.robjects.vectors.DataFrame csv'
. Any help is appreciated.
python rpy2
python rpy2
asked Jan 2 at 5:40
91133039113303
345213
345213
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can try passing a dataframe to the global environment of R using pandas2ri(you might need to install tzlocal for this) and then pass the whole command as a string where R itself returns the value as a dataframe. Look below for a the reference
rdf = pandas2ri.py2ri(self.data)
ro.globalenv['r_timeseries'] = rdf
prediction=ro.r('as.data.frame(stlf(ts(r_timeseries,frequency = 12),h=4,level=c(90)))')
To run you through the code: I am first creating a globalenv dataframe named as r_timeseries and passing it below as a string command which you usually would pass in R as well. Here I am using rpy2 to get forecast for 4 periods using STLF.
Go have a try yourself, I hope this would be of some help to you.
add a comment |
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/3.0/"u003ecc by-sa 3.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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001712%2fhow-to-convert-rpy2-robjects-vectors-dataframe-to-csv%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try passing a dataframe to the global environment of R using pandas2ri(you might need to install tzlocal for this) and then pass the whole command as a string where R itself returns the value as a dataframe. Look below for a the reference
rdf = pandas2ri.py2ri(self.data)
ro.globalenv['r_timeseries'] = rdf
prediction=ro.r('as.data.frame(stlf(ts(r_timeseries,frequency = 12),h=4,level=c(90)))')
To run you through the code: I am first creating a globalenv dataframe named as r_timeseries and passing it below as a string command which you usually would pass in R as well. Here I am using rpy2 to get forecast for 4 periods using STLF.
Go have a try yourself, I hope this would be of some help to you.
add a comment |
You can try passing a dataframe to the global environment of R using pandas2ri(you might need to install tzlocal for this) and then pass the whole command as a string where R itself returns the value as a dataframe. Look below for a the reference
rdf = pandas2ri.py2ri(self.data)
ro.globalenv['r_timeseries'] = rdf
prediction=ro.r('as.data.frame(stlf(ts(r_timeseries,frequency = 12),h=4,level=c(90)))')
To run you through the code: I am first creating a globalenv dataframe named as r_timeseries and passing it below as a string command which you usually would pass in R as well. Here I am using rpy2 to get forecast for 4 periods using STLF.
Go have a try yourself, I hope this would be of some help to you.
add a comment |
You can try passing a dataframe to the global environment of R using pandas2ri(you might need to install tzlocal for this) and then pass the whole command as a string where R itself returns the value as a dataframe. Look below for a the reference
rdf = pandas2ri.py2ri(self.data)
ro.globalenv['r_timeseries'] = rdf
prediction=ro.r('as.data.frame(stlf(ts(r_timeseries,frequency = 12),h=4,level=c(90)))')
To run you through the code: I am first creating a globalenv dataframe named as r_timeseries and passing it below as a string command which you usually would pass in R as well. Here I am using rpy2 to get forecast for 4 periods using STLF.
Go have a try yourself, I hope this would be of some help to you.
You can try passing a dataframe to the global environment of R using pandas2ri(you might need to install tzlocal for this) and then pass the whole command as a string where R itself returns the value as a dataframe. Look below for a the reference
rdf = pandas2ri.py2ri(self.data)
ro.globalenv['r_timeseries'] = rdf
prediction=ro.r('as.data.frame(stlf(ts(r_timeseries,frequency = 12),h=4,level=c(90)))')
To run you through the code: I am first creating a globalenv dataframe named as r_timeseries and passing it below as a string command which you usually would pass in R as well. Here I am using rpy2 to get forecast for 4 periods using STLF.
Go have a try yourself, I hope this would be of some help to you.
answered Jan 2 at 7:11


Amit AmolaAmit Amola
444618
444618
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001712%2fhow-to-convert-rpy2-robjects-vectors-dataframe-to-csv%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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