小编mar*_*rbu的帖子

python pandas read_excel:sep参数可用吗?

我正在尝试使用 .xlsx 将 .xlsx 读入 pandas 数据帧
pd.read_excel("C:/...")

问题是我只得到一列,其中包含用“,”分隔的所有数据。

|---| "Country","Year","Export" |  
|---|---------------------------|  
| 0 | Canada,2017,3002          |  
| 1 | Bulgaria,2016,3960        |  
| 2 | Germany,2015,3818         |
Run Code Online (Sandbox Code Playgroud)

但这不是我想要的格式...我想得到如下表所示的三列。

|---| "Country"    | "Year"   | "Export"   |  
|---|--------------|----------| -----------|  
|1  | Canada       | 2017     |       3002 |  
|2  | Bulgaria     | 2016     |       3960 |  
|3  | Germany      | 2015     |       3818 |
Run Code Online (Sandbox Code Playgroud)

所以我正在寻找 pd.read_csv 中包含的 sep=',' 或 delimiter=',' 参数。我已经完成了 pandas.read_excel 的文档,但还没有找到处理这个问题的参数......

谢谢!

python pandas

6
推荐指数
1
解决办法
2万
查看次数

idf对排名一个词查询没有影响

我正在阅读这篇文章,它说

请注意,IDF取决于查询词(T)和整个数据库。特别是,文档之间的差异不大。因此,IDF将对1字查询无效。

我不太明白。如果TF-IDF(T) = TF * log(N/dbCount[T])为什么对1字查询无效?

data-retrieval tf-idf

5
推荐指数
1
解决办法
1145
查看次数

通过强类型和运算符重载进行简单的单元检查

我正在阅读Ada 中的强类型,重点是单元检查,并决定自己测试这种幼稚的方法:

procedure Example is
  type Meters is new Float;
  type Meters_Squared is new Float; 
  function "*" (Left, Right : Meters) return Meters_Squared is
  begin
    return Meters_Squared(Float(Left)*Float(Right));
  end;
  len_a : Meters := 10.0;
  len_b : Meters := 15.0;
  surface : Meters_Squared;
  len_sum : Meters;
begin
  len_sum := len_a + len_b; -- ok
  surface := len_a * len_b; -- ok
  len_sum := len_a * len_b; -- invalid
end Example;
Run Code Online (Sandbox Code Playgroud)

现在我知道这实际上并不是实用的方法,我只是将其作为一种学习经验来尝试。根据我到目前为止的尝试,我一定遗漏了一些东西,因为当我尝试编译上面列出的示例时,我没有收到任何错误:

$ make example
gcc -c example.adb
gnatmake …
Run Code Online (Sandbox Code Playgroud)

ada

4
推荐指数
1
解决办法
89
查看次数

Python:如何基于具有二进制内容的文本文件提取DNA序列?

例如,我有一个包含以下序列的fasta文件:

>human1
AGGGCGSTGC
>human2
GCTTGCGCTAG
>human3
TTCGCTAG
Run Code Online (Sandbox Code Playgroud)

如何使用python读取具有以下内容的文本文件来提取序列?1表示真,0表示假.仅提取值为1的序列.

示例文本文件:

0
1
1
Run Code Online (Sandbox Code Playgroud)

预期产量:

>human2
GCTTGCGCTAG
>human3
TTCGCTAG
Run Code Online (Sandbox Code Playgroud)

python bioinformatics fasta biopython python-2.7

0
推荐指数
1
解决办法
1492
查看次数