SELECT * FROM table_a
WHERE time_1 >= to_timestamp('11/01/2014 10:00 PDT', 'MM/DD/YYYY HH24:MI TZ')
Run Code Online (Sandbox Code Playgroud)
time_1是UTC时区,它是带有时区的时间戳。那么,这会给我我想要的东西还是我需要在to_timestamp()函数中执行精确的UTC时间?
我试着分别在pandas数据框中随机播放每一列.这里写的函数:
def shuffle_x(x):
x = x.copy()
np.random.shuffle(x)
return x
def shuffle_table(df):
df_shuffled = df.apply(shuffle_x, raw = True, axis = 0)
return df_shuffled
Run Code Online (Sandbox Code Playgroud)
现在,我正在测试一个包含30000行和1000列的pandas数据帧df,如果我直接这样做shuffle_table(df),这真的很慢,需要超过1500秒.但是,如果我做这样的事情:
df_split = np.split(df, 100, axis = 1)
df_shuffled = pd.concat([shuffle_table(x) for x in df_split], axis = 1)
Run Code Online (Sandbox Code Playgroud)
这要快得多,只需60秒
我最好的客人是这个问题与pandas为生成新数据帧分配空间的方式有关.
此外,我能想出的最快方法是:
tmp_d = {}
for col in df.columns:
tmp_val = df[col].values
np.random.shuffle(tmp_val)
tmp_d[col] = tmp_val
df_shuffled = pd.DataFrame(tmp_d)
df_shuffled = df_shuffled[df.columns]
Run Code Online (Sandbox Code Playgroud)
这大约需要15秒
运行以下代码:
aa = Matrix(0, nrow = 8000000, ncol = 100000, sparse = TRUE)
object.size(aa)
# 401424 bytes
apply(aa, 1, mean)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
asMethod(object)出错:文件中的Cholmod错误'问题太大'../Core/cholmod_dense.c,第105行
在这种情况下,大小aa不是太大,因此我猜apply功能会自动将其转换为密集矩阵.有没有办法使这个工作?我知道这里rowMeans可以轻松替换apply(aa, 1, mean),但如果我想申请其他一些自定义功能怎么办?
我的sapply函数的每个循环都会输出一个*m矩阵.n是固定的,m不是.例如,如果我在R中运行它:
sapply(1:3, function(x) {matrix(1:9, 3)})
Run Code Online (Sandbox Code Playgroud)
它会输出:
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 2 2 2
[3,] 3 3 3
[4,] 4 4 4
[5,] 5 5 5
[6,] 6 6 6
[7,] 7 7 7
[8,] 8 8 8
[9,] 9 9 9
Run Code Online (Sandbox Code Playgroud)
但是,我想要的是这样的:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] 1 4 7 1 4 7 1 4 7
[2,] 2 5 8 2 5 8 2 5 8
[3,] 3 6 9 3 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用python-devel以下方式安装yum:
sudo yum install python-devel
Run Code Online (Sandbox Code Playgroud)
并得到以下内容:
Resolving Dependencies
--> Running transaction check
---> Package python-devel.x86_64 0:2.7.5-76.el7 will be installed
--> Processing Dependency: python(x86-64) = 2.7.5-76.el7 for package: python-devel-2.7.5-76.el7.x86_64
--> Finished Dependency Resolution
Error: Package: python-devel-2.7.5-76.el7.x86_64 (base)
Requires: python(x86-64) = 2.7.5-76.el7
Installed: python-2.7.5-80.el7_6.x86_64 (@updates)
python(x86-64) = 2.7.5-80.el7_6
Available: python-2.7.5-68.el7.x86_64 (base)
python(x86-64) = 2.7.5-68.el7
Available: python-2.7.5-69.el7_5.x86_64 (updates)
python(x86-64) = 2.7.5-69.el7_5
Available: python-2.7.5-76.el7.x86_64 (base)
python(x86-64) = 2.7.5-76.el7
You could try using --skip-broken to work around the problem
You could …Run Code Online (Sandbox Code Playgroud)