这是我生成数据帧的代码:
import pandas as pd
import numpy as np
dff = pd.DataFrame(np.random.randn(1,2),columns=list('AB'))
Run Code Online (Sandbox Code Playgroud)
然后我得到了数据帧:
+------------+---------+--------+
| | A | B |
+------------+---------+---------
| 0 | 0.626386| 1.52325|
+------------+---------+--------+
Run Code Online (Sandbox Code Playgroud)
当我输入命令时:
dff.mean(axis=1)
Run Code Online (Sandbox Code Playgroud)
我有 :
0 1.074821
dtype: float64
Run Code Online (Sandbox Code Playgroud)
根据pandas的引用,axis = 1代表列,我期望命令的结果
A 0.626386
B 1.523255
dtype: float64
Run Code Online (Sandbox Code Playgroud)
所以这是我的问题:熊猫中的轴是什么意思?
在java中,BitSet的内部数据存储为long []而不是int [],我想知道为什么?这是jdk中的代码:
/**
* The internal field corresponding to the serialField "bits".
*/
private long[] words;
Run Code Online (Sandbox Code Playgroud)
如果这完全取决于性能,我想知道为什么long []存储会获得更好的性能.
我有一个矩阵如下:
jerry peter king
jerry 1 0 0
peter 0 1 0
king 1 1 1
Run Code Online (Sandbox Code Playgroud)
现在我想用下面的代码绘制一个代表矩阵的图形:
t <- read.table("../data/table.dat");
adjm <- data.matrix(t);
g1 <- graph.adjacency(adjm,add.colnames=NULL);
plot(g1, main="social network", vertex.color="white", edge.color="grey", vertex.size=8,
vertex.frame.color="yellow");
Run Code Online (Sandbox Code Playgroud)
顶点的标签是id,所以我的问题是如何通过矩阵的dimnames设置顶点的标签?
我试过这个代码
vertex.label=attr(adjm,"dimnames")
Run Code Online (Sandbox Code Playgroud)
但得到错误的图表.
我尝试锁定一个文件并使用以下代码写入它:
public class TrainSetBuildTask implements Runnable {
private String pathname;
public TrainSetBuildTask(String pathname){
this.pathname = pathname;
}
@Override
public void run() {
try {
String content = "content\n";
//write to a file
FileOutputStream os = new FileOutputStream(new File(pathname), true);
FileChannel channel = os.getChannel();
FileLock lock = channel.tryLock();
if (lock != null) {
ByteBuffer bytes = ByteBuffer.wrap(content.getBytes());
channel.write(bytes);
lock.release();
}
channel.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
并新建两个带有该类实例的线程:
String pathname = "/home/sjtu123/test.arff";
TrainSetBuildTask task1 = new TrainSetBuildTask(pathname); …Run Code Online (Sandbox Code Playgroud) 我知道这个问题被多次询问,当我在我的选择查询中包含多个参数时遵循指南时仍然会遇到问题.这是我的配置文件:
<select id="selectByDate" parameterType="map" resultMap="campaignStats">
SELECT * FROM CampaignStats WHERE statsDate >= #{start} AND statsDate <= #{end}
</select>
Run Code Online (Sandbox Code Playgroud)
这是我的Java代码:
public List<DpCampaignStats> selectByDate(Date start, Date end){
SqlSession session = sqlSessionFactory.openSession();
try {
Map<String, Date> map = new HashMap<String, Date>();
map.put("start", start);
map.put("end", end);
List<DpCampaignStats> list = session.selectList("DpCampaignStats.selectByDate", map);
return list;
} finally {
session.close();
}
}
Run Code Online (Sandbox Code Playgroud)
但我收到错误:java.lang.ExceptionInInitializerError这意味着我的配置文件中有一些错误,我找不到原因.
我将图像放在xcode的图像视图中并设置"缩放到适合"模式,但我发现图像不符合图像视图的大小.那么如何使图像适合ios中图像视图的大小?
以下是故事板的截图.
我正在使用xcode 6.3,swift 1.2并使用cocoapods安装"JSQMessagesViewController"库.这是我的pod文件:
pod 'JSQMessagesViewController'
Run Code Online (Sandbox Code Playgroud)
和我的桥文件:
#import <JSQMessagesViewController/JSQMessages.h>
Run Code Online (Sandbox Code Playgroud)
然后我得到错误:
'JSQMessagesViewController/JSQMessages.h' file not found with <angled> include; use "quotes" instead
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会出错.当我用更新桥文件时
#import "JSQMessagesViewController/JSQMessages.h"
Run Code Online (Sandbox Code Playgroud)
我收到了错误
JSQMessagesViewController/JSQSystemSoundPlayer+JSQMessages.h:19:9: 'JSQSystemSoundPlayer/JSQSystemSoundPlayer.h' file not found with <angled> include; use "quotes" instead
Run Code Online (Sandbox Code Playgroud)
这真的让我感到困惑,因为错误是在JSQMessagesViewController的源代码中,我无法修改.我用Google搜索了一天,没有办法解决它.由于JSQMessagesViewController库在githup中如此受欢迎,我相信必须有人知道如何修复它.
由于elasticsearch的modules子项目和plugins子项目中的类都是Plugin的子类,所以我想知道elasticsearch插件和elasticsearch模块之间的区别。
例如 lang-painless 模块
public final class PainlessPlugin extends Plugin implements ScriptPlugin
Run Code Online (Sandbox Code Playgroud)
lang-python 插件
public class PythonPlugin extends Plugin implements ScriptPlugin
Run Code Online (Sandbox Code Playgroud)
也许他们的实现没有区别,elastic公司的人将必要的类放在模块子项目中,将不必要的类放在插件子产品中。希望elasticsearch的开发者之一能够解释一下。
数组中有许多数字,除了出现一次的一个特殊数字外,每个数字出现三次.这是一个问题:如何在数组中找到特殊数字?
现在我只能提出一些基数排序和快速排序的方法,这些方法无法利用问题的性质.所以我需要一些其他的算法.
谢谢你的帮助.
我正在使用Yii的权限扩展并收到此错误:
There must be at least one superuser!
Run Code Online (Sandbox Code Playgroud)
我不知道这superuser意味着什么,因为我使用的是用户admin和demo的默认身份验证.阅读权限扩展的文档后,我尝试使用以下命令配置权限:
'rights'=>array(
'superuserName'=>'admin',
'install'=>true
),
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我搜索了互联网但没有结果.
这是我的代码:
double getRevenue(KeywordGroupKey key) {
Double r = revenueMap.get(key);
System.out.println(key + "\t" + key.hashCode());
for (KeywordGroupKey other : revenueMap.keySet()) {
System.out.println(other.toString() + "\t" + other.hashCode());
if(other.equals(key))
System.out.println("equals here...");
}
if(r == null)
r = 0.0;
return r;
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
????????|"???" 955095524
brand+????|???? 726983298
brand-?????|?????? -713384514
brand-???|??? 2029153675
brand+????|????? 261410621
????????|"???" 955095524
equals here...
Run Code Online (Sandbox Code Playgroud)
所以这个方法返回的值是空的很奇怪,为什么会发生这种情况呢?由于在revenueMap中有一个键具有相同的哈希码并且与参数键相等.以下是revenueMap和key的当前状态:
{brand+????|????=28.0, brand-?????|??????=49.9, brand-???|???=21.0, brand+????|?????=167.0, ????????|"???"=9.9}
????????|"???"
Run Code Online (Sandbox Code Playgroud) 假设我有一CategoryKey节课:
public class CategoryKey {
public int layer;
public int parent;
public int child;
}
Run Code Online (Sandbox Code Playgroud)
我尝试将其中的许多实例放在a中Set,但我们知道HashSet它不适合存储自定义类的实例.那么如何扩展java类HashSet以满足我的要求呢?或者我如何创建一个新的类实现接口Set来解决同样的问题?