import re
#Creating several new colums with a for loop and adding them to the original df.
#Creating permutations for a second level of binary variables for df
for i in list_ib:
for j in list_ib:
if i == j:
break
else:
bina = df[i]*df[j]
print(i,j)
Run Code Online (Sandbox Code Playgroud)
i 是属于数据框 (df) 的二进制列,j 是相同的列。我已经计算了每列与每列的乘法。我现在的问题是,如何将所有新的二进制产品列添加到原始 df 中?
我试过了:
df = df + df[i,j,bina]
Run Code Online (Sandbox Code Playgroud)
但我没有得到我需要的结果。有什么建议?
我试图从POSIXct格式的一小时后删除秒:
#"2016-04-02 10:33:45 COT" "2016-04-02 22:19:24 COT"
#"2016-04-09 17:47:13 COT" "2016-04-13 16:56:23 COT"
x <- structure(c(1459589625, 1459631964, 1460220433, 1460562983),
class = c("POSIXct", "POSIXt"), tzone = "")
Run Code Online (Sandbox Code Playgroud)
我正在尝试这个,但我没有看到结果:
y <- as.POSIXct(x, format = "%d/%m/%Y %H:%M")
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的 Python 3.5 安装 pygmaps:
pip install pygmaps
Run Code Online (Sandbox Code Playgroud)
我收到这条消息:
找不到满足 pygmaps 要求的版本(来自版本:)没有找到与 pygmaps 匹配的发行版
我在 R 中有这个代码
a <- c(NA)
a<- matrix(c(a), nrow = 80)
a<-as.data.frame(a)
a[ c(T,F,F,F), ] <- "aaa"
a[ c(F,T,F,F), ] <- "bbb"
a[ c(F,F,T,F), ] <- "ccc"
a[ c(F,F,F,T), ] <- "ddd"
Run Code Online (Sandbox Code Playgroud)
如何在 python 中将它复制为熊猫数据框?
str(a)
Run Code Online (Sandbox Code Playgroud)
'data.frame':80 个观察。共 1 个变量:
$ V1: chr "aaa" "bbb" "ccc" "ddd" ...