我正在尝试获得纬度和经度坐标的时区,但我遇到了一些问题错误可能是非常基本的
我在数据库中有一个表,大约有600行.每行包含一个lat长坐标,用于世界某处我想将这些坐标输入函数然后检索时区.目的是将这600个地点中每个地点都有本地时间戳的事件转换为UTC时间
当我尝试运行代码时,我收到错误geonames is not defined.我申请了一个地理名称帐户.
我想我刚刚将函数文件保存在错误的目录或简单的东西中.谁能帮忙
#-------------------------------------------------------------------------------
# Converts latitude longitude into a time zone
# REF: https://gist.github.com/pamelafox/2288222
# REF: http://blog.pamelafox.org/2012/04/converting-addresses-to-timezones-in.html
#-------------------------------------------------------------------------------
geonames_client = geonames.GeonamesClient('Username_alpha')
geonames_result = geonames_client.find_timezone({'lat': 48.871236, 'lng': 2.77928})
user.timezone = geonames_result['timezoneId']
Run Code Online (Sandbox Code Playgroud) 有没有人能够将R中的SharePoint列表导入为数据帧?
我有两个单独的数据源,一个来自SharePoint列表,另一个来自我希望运行分析的数据库.我能够毫无问题地连接到数据库,但似乎无法找到连接到SharePoint列表的任何内容.
SharePoint服务器是2007
我正在尝试使用以下代码循环遍历 Polars 记录集:
\n\nimport polars as pl\n\nmydf = pl.DataFrame(\n {"start_date": ["2020-01-02", "2020-01-03", "2020-01-04"],\n "Name": ["John", "Joe", "James"]})\n\nprint(mydf)\n\n\xe2\x94\x82start_date \xe2\x94\x86 Name \xe2\x94\x82\n\xe2\x94\x82 --- \xe2\x94\x86 --- \xe2\x94\x82\n\xe2\x94\x82 str \xe2\x94\x86 str \xe2\x94\x82\n\xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xaa\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1\n\xe2\x94\x82 2020-01-02 \xe2\x94\x86 John \xe2\x94\x82\n\xe2\x94\x82 2020-01-03 \xe2\x94\x86 Joe \xe2\x94\x82\n\xe2\x94\x82 2020-01-04 \xe2\x94\x86 James \xe2\x94\x82\n\nfor row in mydf.rows():\n print(row)\n\n('2020-01-02', 'John')\n('2020-01-03', 'Joe')\n('2020-01-04', 'James')\n\nRun Code Online (Sandbox Code Playgroud)\n有没有办法使用命名列而不是索引来专门引用“名称”?在 Pandas 中,这看起来像:
\nimport pandas as pd\n\nmydf = pd.DataFrame(\n {"start_date": ["2020-01-02", "2020-01-03", "2020-01-04"],\n "Name": ["John", "Joe", "James"]})\n\nfor index, row in mydf.iterrows():\n mydf['Name'][index]\n\n'John'\n'Joe'\n'James'\nRun Code Online (Sandbox Code Playgroud)\n 我已经根据@Jim M.的帮助在R中创建了一个函数.
当我运行该函数时,我得到错误:错误:未知列'rawdata' 当查看调试器时,我收到消息:Eval中的Rcpp :: exception(expr,envir,enclos):未知列'rawdata'
然而,当我查看环境窗口时,我可以看到2个已传递给函数的变量,它们包含具有7个级别因子的信息rawdata和具有28个级别的refdata
function (refdata, rawdata)
{
wordlist <- expand.grid(rawdata = rawdata, refdata = refdata, stringsAsFactors = FALSE)
wordlist %>% group_by(rawdata) %>% mutate(match_score = jarowinkler(rawdata, refdata)) %>%
summarise(match = match_score[which.max(match_score)], matched_to = ref[which.max(match_score)])
}
Run Code Online (Sandbox Code Playgroud) 我在R中有两个类型字符向量
我希望能够使用jarowinkler将引用列表与原始字符列表进行比较,并指定%相似度得分.因此,例如,如果我有10个参考项目和20个原始数据项目,我希望能够获得比较的最佳分数以及算法与之匹配的内容(因此2个向量为10).如果我有大小为8和10个参考项目的原始数据,我应该只得到8个项目的2个向量结果,每个项目的匹配和得分最高
item,match,matched_to ice,78,ice-cream
下面是我的代码,没什么可看的.
NumItems.Raw = length(words)
NumItems.Ref = length(Ref.Desc)
for (item in words)
{
for (refitem in Ref.Desc)
{
jarowinkler(refitem,item)
# Find Best match Score
# Find Best Item in reference table
# Add both items to vectors
# decrement NumItems.Raw
# Loop
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用我使用随机森林Algorthim的泰坦尼克数据集在Kaggle上练习R.
下面是代码
fit <- randomForest(as.factor(Survived) ~ Pclass + Sex + Age_Bucket + Embarked
+ Age_Bucket + Fare_Bucket + F_Name + Title + FamilySize + FamilyID,
data=train, importance=TRUE, ntree=5000)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Error in randomForest.default(m, y, ...) :
NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning messages:
1: In data.matrix(x) : NAs introduced by coercion
2: In data.matrix(x) : NAs introduced by coercion
3: In data.matrix(x) : NAs introduced by coercion
4: In data.matrix(x) : NAs introduced by coercion
Run Code Online (Sandbox Code Playgroud)
我的数据如下所示
$ …Run Code Online (Sandbox Code Playgroud) 我有一个包含两列的数据框.我想在数据集中添加另外两列,其中包含基于聚合的计数.
df <- structure(list(ID = c(1045937900, 1045937900),
SMS.Type = c("DF1", "WCB14"),
SMS.Date = c("12/02/2015 19:51", "13/02/2015 08:38"),
Reply.Date = c("", "13/02/2015 09:52")
), row.names = 4286:4287, class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
我想简单地计算SMS.Type和Reply.Date的实例数,其中没有null.所以在下面的玩具示例中,我将为SMS.Type生成2,为Reply.Date生成1
然后我想将它作为总计数添加到数据框中(我知道它们将复制出原始数据集中的行数但是没关系)
我一直在玩聚合和计数功能,但无济于事
mytempdf <-aggregate(cbind(testtrain$SMS.Type,testtrain$Response.option)~testtrain$ID,
train,
function(x) length(unique(which(!is.na(x)))))
mytempdf <- aggregate(testtrain$Reply.Date~testtrain$ID,
testtrain,
function(x) length(which(!is.na(x))))
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
感谢您的时间
我正在使用 RMarkdown 编写一些大学作业 我使用下面的代码创建了一个表格,需要将其导出到 Microsoft Word
谁能告诉我如何添加描述表中数据的标签,或者我是否必须在 MS Word 中执行此操作
---
title: "Data"
author: "foo"
date: "2 July 2016"
output:
word_document:
bibliography: bibliography.bib
---
kable(table(Rawdata$Var1, Rawdata$Var2))
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置 R 以使用 Visual Studio 代码。当我使用键CTRL+执行一行时,ENTER出现错误“win32 无法使用 R”。
我正在遵循这篇中篇文章中提出的建议,我已经设法安装了所有扩展,但不确定在哪里应用点“4。最后在编辑器的 settings.json 中添加这些行”
我看过这篇文章,它描述了(我认为)如何更新 settings.JSON 但老实说,我不确定在哪里以及这是否是在原始帖子中添加行的正确位置。
我 PC 上的 JSON 文件如下所示
{
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace",
"gitlens.codeLens.scopes": [
"document"
]
}
}
Run Code Online (Sandbox Code Playgroud)
有人能指出我正确的方向吗
谢谢
我想使用 R 和tidytext包对相似的单词进行聚类。我已经创建了我的令牌,现在想将其转换为矩阵以对其进行聚类。我想尝试一些令牌技术,看看哪种技术提供了最紧凑的集群。
我的代码如下(取自widyr包的文档)。我只是无法进行下一步。任何人都可以帮忙吗?
library(janeaustenr)
library(dplyr)
library(tidytext)
# Comparing Jane Austen novels
austen_words <- austen_books() %>%
unnest_tokens(word, text)
# closest books to each other
closest <- austen_words %>%
pairwise_similarity(book, word, n) %>%
arrange(desc(similarity))
Run Code Online (Sandbox Code Playgroud)
我知道围绕closest. 这段代码会让我到达那里,但我不知道如何从上一节转到矩阵。
d <- dist(m)
kfit <- kmeans(d, 4, nstart=100)
Run Code Online (Sandbox Code Playgroud)