我有一个Data.Frame,它由行组成,每个行都是URL,但当我运行“typeof”时,它的格式是一个列表。当我试图将它绑定到字符或数字格式的其他数据帧时,这会产生一些问题。我试图将这个Data.Frame转换为一个标准的Data.Frame,它显示了每一行的因子级别列表,每个URL都保持不变,占据每一行(长度不变)。
structure(c(35L, 35L, 34L, 33L, 33L, 33L, 32L, 32L, 32L, 32L), .Label = c("/Archives/edgar/data/0001218981/000117911016022379/0001179110-16-022379-index.htm",
"/Archives/edgar/data/0001218981/000117911016028590/0001179110-16-028590-index.htm",
"/Archives/edgar/data/0001218981/000117911016028764/0001179110-16-028764-index.htm",
"/Archives/edgar/data/0001218981/000117911016028975/0001179110-16-028975-index.htm",
"/Archives/edgar/data/0001218981/000117911016029122/0001179110-16-029122-index.htm",
"/Archives/edgar/data/0001218981/000117911016030044/0001179110-16-030044-index.htm",
"/Archives/edgar/data/0001218981/000117911016031144/0001179110-16-031144-index.htm",
"/Archives/edgar/data/0001218981/000117911016032519/0001179110-16-032519-index.htm",
"/Archives/edgar/data/0001218981/000117911017003489/0001179110-17-003489-index.htm",
"/Archives/edgar/data/0001218981/000117911017009339/0001179110-17-009339-index.htm",
"/Archives/edgar/data/0001218981/000117911017009836/0001179110-17-009836-index.htm",
"/Archives/edgar/data/0001218981/000117911017011451/0001179110-17-011451-index.htm",
"/Archives/edgar/data/0001218981/000117911017011684/0001179110-17-011684-index.htm",
"/Archives/edgar/data/0001218981/000117911017011782/0001179110-17-011782-index.htm",
"/Archives/edgar/data/0001218981/000117911017013512/0001179110-17-013512-index.htm",
"/Archives/edgar/data/0001218981/000117911017013668/0001179110-17-013668-index.htm",
"/Archives/edgar/data/0001218981/000117911017013817/0001179110-17-013817-index.htm",
"/Archives/edgar/data/0001218981/000117911017014024/0001179110-17-014024-index.htm",
"/Archives/edgar/data/0001218981/000117911017014676/0001179110-17-014676-index.htm",
"/Archives/edgar/data/0001218981/000117911017015379/0001179110-17-015379-index.htm",
"/Archives/edgar/data/0001218981/000117911018004779/0001179110-18-004779-index.htm",
"/Archives/edgar/data/0001218981/000117911018008826/0001179110-18-008826-index.htm",
"/Archives/edgar/data/0001218981/000117911018009648/0001179110-18-009648-index.htm",
"/Archives/edgar/data/0001218981/000117911018009739/0001179110-18-009739-index.htm",
"/Archives/edgar/data/0001218981/000117911018011490/0001179110-18-011490-index.htm",
"/Archives/edgar/data/0001218981/000117911019004050/0001179110-19-004050-index.htm",
"/Archives/edgar/data/0001218981/000117911019004286/0001179110-19-004286-index.htm",
"/Archives/edgar/data/0001218981/000117911019004323/0001179110-19-004323-index.htm",
"/Archives/edgar/data/0001218981/000117911019005598/0001179110-19-005598-index.htm",
"/Archives/edgar/data/0001218981/000117911019007384/0001179110-19-007384-index.htm",
"/Archives/edgar/data/0001218981/000117911019012669/0001179110-19-012669-index.htm",
"/Archives/edgar/data/0001218981/000117911019013159/0001179110-19-013159-index.htm",
"/Archives/edgar/data/0001218981/000117911020000425/0001179110-20-000425-index.htm",
"/Archives/edgar/data/0001218981/000117911020004224/0001179110-20-004224-index.htm",
"/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm",
"/Archives/edgar/data/0001218981/000120919115082536/0001209191-15-082536-index.htm",
"/Archives/edgar/data/0001218981/000120919115083517/0001209191-15-083517-index.htm",
"/Archives/edgar/data/0001218981/000120919116095084/0001209191-16-095084-index.htm",
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001015739", "/cgi-bin/browse-edgar?action=getcompany&CIK=0001218981&owner=include",
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001326732", "/cgi-bin/browse-edgar?action=getcurrent",
"/cgi-bin/own-disp?action=getissuer&CIK=0001015739", "/cgi-bin/own-disp?action=getissuer&CIK=0001326732",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=filings-ASC",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=ownership-data-ASC",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=period-of-report-ASC",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=type-of-owner-ASC",
"/edgar/searchedgar/webusers.htm", "/index.htm", "javascript:history.back()"
), class = "factor")
structure(list(web = structure(c(35L, 35L, 34L, 33L, 33L, 33L,
32L, 32L, 32L, 32L, 31L, 31L, 31L, 30L, 29L, 27L, 28L, 27L, 26L,
26L, 25L, 24L, 24L, 24L, 23L, 23L, 23L, 23L, 23L, 22L, 22L, 22L,
21L, 20L, 20L, 19L, 19L, 18L, 18L, 18L, 17L, 17L, 17L, 16L, 16L,
16L, 15L, 15L, 15L, 14L, 14L, 13L, 13L, 13L, 12L, 12L, 11L, 10L,
9L, 8L, 7L, 7L, 6L, 6L, 6L, 5L, 4L, 4L, 3L, 2L, 2L, 2L, 1L, 38L,
38L, 37L, 37L, 37L, 36L, 36L), .Label = c("/Archives/edgar/data/0001218981/000117911016022379/0001179110-16-022379-index.htm",
"/Archives/edgar/data/0001218981/000117911016028590/0001179110-16-028590-index.htm",
"/Archives/edgar/data/0001218981/000117911016028764/0001179110-16-028764-index.htm",
"/Archives/edgar/data/0001218981/000117911016028975/0001179110-16-028975-index.htm",
"/Archives/edgar/data/0001218981/000117911016029122/0001179110-16-029122-index.htm",
"/Archives/edgar/data/0001218981/000117911016030044/0001179110-16-030044-index.htm",
"/Archives/edgar/data/0001218981/000117911016031144/0001179110-16-031144-index.htm",
"/Archives/edgar/data/0001218981/000117911016032519/0001179110-16-032519-index.htm",
"/Archives/edgar/data/0001218981/000117911017003489/0001179110-17-003489-index.htm",
"/Archives/edgar/data/0001218981/000117911017009339/0001179110-17-009339-index.htm",
"/Archives/edgar/data/0001218981/000117911017009836/0001179110-17-009836-index.htm",
"/Archives/edgar/data/0001218981/000117911017011451/0001179110-17-011451-index.htm",
"/Archives/edgar/data/0001218981/000117911017011684/0001179110-17-011684-index.htm",
"/Archives/edgar/data/0001218981/000117911017011782/0001179110-17-011782-index.htm",
"/Archives/edgar/data/0001218981/000117911017013512/0001179110-17-013512-index.htm",
"/Archives/edgar/data/0001218981/000117911017013668/0001179110-17-013668-index.htm",
"/Archives/edgar/data/0001218981/000117911017013817/0001179110-17-013817-index.htm",
"/Archives/edgar/data/0001218981/000117911017014024/0001179110-17-014024-index.htm",
"/Archives/edgar/data/0001218981/000117911017014676/0001179110-17-014676-index.htm",
"/Archives/edgar/data/0001218981/000117911017015379/0001179110-17-015379-index.htm",
"/Archives/edgar/data/0001218981/000117911018004779/0001179110-18-004779-index.htm",
"/Archives/edgar/data/0001218981/000117911018008826/0001179110-18-008826-index.htm",
"/Archives/edgar/data/0001218981/000117911018009648/0001179110-18-009648-index.htm",
"/Archives/edgar/data/0001218981/000117911018009739/0001179110-18-009739-index.htm",
"/Archives/edgar/data/0001218981/000117911018011490/0001179110-18-011490-index.htm",
"/Archives/edgar/data/0001218981/000117911019004050/0001179110-19-004050-index.htm",
"/Archives/edgar/data/0001218981/000117911019004286/0001179110-19-004286-index.htm",
"/Archives/edgar/data/0001218981/000117911019004323/0001179110-19-004323-index.htm",
"/Archives/edgar/data/0001218981/000117911019005598/0001179110-19-005598-index.htm",
"/Archives/edgar/data/0001218981/000117911019007384/0001179110-19-007384-index.htm",
"/Archives/edgar/data/0001218981/000117911019012669/0001179110-19-012669-index.htm",
"/Archives/edgar/data/0001218981/000117911019013159/0001179110-19-013159-index.htm",
"/Archives/edgar/data/0001218981/000117911020000425/0001179110-20-000425-index.htm",
"/Archives/edgar/data/0001218981/000117911020004224/0001179110-20-004224-index.htm",
"/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm",
"/Archives/edgar/data/0001218981/000120919115082536/0001209191-15-082536-index.htm",
"/Archives/edgar/data/0001218981/000120919115083517/0001209191-15-083517-index.htm",
"/Archives/edgar/data/0001218981/000120919116095084/0001209191-16-095084-index.htm",
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001015739", "/cgi-bin/browse-edgar?action=getcompany&CIK=0001218981&owner=include",
"/cgi-bin/browse-edgar?action=getcompany&CIK=0001326732", "/cgi-bin/browse-edgar?action=getcurrent",
"/cgi-bin/own-disp?action=getissuer&CIK=0001015739", "/cgi-bin/own-disp?action=getissuer&CIK=0001326732",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=filings-ASC",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=ownership-data-ASC",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=period-of-report-ASC",
"/cgi-bin/own-disp?action=getowner&CIK=0001218981&sortid=type-of-owner-ASC",
"/edgar/searchedgar/webusers.htm", "/index.htm", "javascript:history.back()"
), class = "factor")), row.names = c(NA, -80L), class = "data.frame")
感谢帮助!
如果需要将该列转换为character
,只需提取该列,并将用作.character
test2$web <- as.character(test2$web)
-检查结构
str(test2)
#'data.frame': 80 obs. of 1 variable:
# $ web: chr "/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm" "/Archives/edgar/data/0001218981/000117911020004802/0001179110-20-004802-index.htm" "/Archives/edgar/data/0001218981/000117911020004224/0001179110-20-004224-index.htm" "/Archives/edgar/data/0001218981/000117911020000425/0001179110-20-000425-index.htm" ...
我正在做一些关于Java8流特性的练习,所以我想把这些知识应用到将数字串转换成整数列表的问题上 一个典型的测试看起来像
问题内容: 我有一个清单说: 如何在不触及字符串的情况下转换预期的数字? 感谢您的帮助。 问题答案:
我想使用python将字符串转换成整数列表。一些例子可能是: 有没有快速简单的方法来做到这一点?
我试图将JSON解析到我的对象。json的一个字段包含[1,2,3,4],这是一个int s的列表。但是我的objects字段包含
问题内容: 我有一个清单 我想将其转换为字典 我该怎么做? 问题答案: 采用: 返回: 如果需要整数,请在以下位置更改分配: 这将给出:
问题内容: 我有一个pandas数据框。列之一包含一个列表。我希望该列为单个字符串。 例如,我的列表[‘one’,’two’,‘3’]应该简单地是‘1、2、3’ 给我[‘一个,两个,三个],[‘四个’,’五个’,’六个’],其中第二个列表来自下一行。不用说,对于数百万行,这种跨行连接不仅是不正确的,而且还会杀死我的内存。 问题答案: 在转换列表之前,您当然不应该转换为字符串。尝试: 另请注意,会将