I have a question with writing a dataframe format to R.
我有一个问题,要将数据帧格式写入R.
I have 1000 column X 77 row data. I want to write this dataframe to R data.
我有1000列X 77行数据。我想将此数据帧写入R数据。
When I use function of
当我使用的功能
r_dataframe = com.convert_to_r_dataframe(df)
it gives me an error like dataframe object has no arttribute type.
它给我一个像dataframe对象没有arttribute类型的错误。
When I see the code of com.convert_to_r_dataframe(). it just get the column of dataframe, and get the colunm.dtype.type. In this moment, the column is dataframe, I think large columns dataframe has inside dataframes? Any one have some idea to solve this problem?
当我看到com.convert_to_r_dataframe()的代码时。它只是获取数据帧的列,并获取colunm.dtype.type。在这一刻,列是数据帧,我认为大列数据帧有内部数据帧?任何人都有一些想法来解决这个问题?
2 个解决方案
#1
3
The data.frame transfer from Python to R could be accomplished with the feather format. Via this link you can find more information.
从Python到R的data.frame传输可以使用羽化格式完成。通过此链接,您可以找到更多信息。
Quick example.
快速举例。
Export in Python:
用Python导出:
import feather
path = 'my_data.feather'
feather.write_dataframe(df, path)
Import in R:
在R中导入:
library(feather)
path <- "my_data.feather"
df <- read_feather(path)
In this case you'll have the data in R as a data.frame. You can then decide to write it to an RData file.
在这种情况下,您将R中的数据作为data.frame。然后,您可以决定将其写入RData文件。
save(df, file = 'my_data.RData')
#2
4
simplest, bestest practical solution is to export in csv
最简单,最实用的解决方案是在csv中导出
import pandas as pd
dataframe.to_csv('mypath/file.csv')
and then read in R using read.csv
然后使用read.csv读入R.
#1
3
The data.frame transfer from Python to R could be accomplished with the feather format. Via this link you can find more information.
从Python到R的data.frame传输可以使用羽化格式完成。通过此链接,您可以找到更多信息。
Quick example.
快速举例。
Export in Python:
用Python导出:
import feather
path = 'my_data.feather'
feather.write_dataframe(df, path)
Import in R:
在R中导入:
library(feather)
path <- "my_data.feather"
df <- read_feather(path)
In this case you'll have the data in R as a data.frame. You can then decide to write it to an RData file.
在这种情况下,您将R中的数据作为data.frame。然后,您可以决定将其写入RData文件。
save(df, file = 'my_data.RData')
#2
4
simplest, bestest practical solution is to export in csv
最简单,最实用的解决方案是在csv中导出
import pandas as pd
dataframe.to_csv('mypath/file.csv')
and then read in R using read.csv
然后使用read.csv读入R.