我有一个名为" transactions4.csv"的csv文件;包含如下所示的值:
p %>%
export(file = "filename.svg",
selenium = RSelenium::rsDriver(browser = "chrome",
extraCapabilities = list(
chromeOptions =
list(prefs = list(
"profile.default_content_settings.popups" = 0L,
"download.prompt_for_download" = FALSE,
"download.default_directory" = getwd())
))))
这是我到目前为止所拥有的:
column 1|column 2
--------|---------
12345 | 10
23456 | -15
12376 | 10
56842 | 25
45678 | -5
78324 | 20
这会打印文件中的值,但我不确定如何将每列放入数组中。
答案 0 :(得分:1)
T
+ as_matrix
df.T.as_matrix()
Out[70]:
array([[12345, 23456, 12376, 56842, 45678, 78324],
[ 10, -15, 10, 25, -5, 20]], dtype=int64)
答案 1 :(得分:1)
您还可以查询.values
属性。
x = df.values.T
print(x)
array([[12345, 23456, 12376, 56842, 45678, 78324],
[ 10, -15, 10, 25, -5, 20]])
如果您希望每个列都在一个单独的数组中,只需解压缩它们:
i, j = x
print(i)
array([12345, 23456, 12376, 56842, 45678, 78324])
print(j)
array([ 10, -15, 10, 25, -5, 20])