小编Ste*_*eel的帖子

将<li>元素居中而不考虑要点

我不确定如何将li元素放在浅绿色空间中,仅基于我围绕它们创建的绿色正方形。截至目前,CSS包括居中时项目符号要占用的空间,我不希望这样做。

#square {
  position: fixed;
  width: 350px;
  height: 100%;
  top: 0px;
  left: 0px;
  background-color: rgb(230, 255, 230);
}

ul {
  position: relative;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

li {
  margin-top: 40px;
  padding-left: 75px;
  border-color: white;
  border-width: 2px;
  border-style: solid;
  padding: 5px 20px 5px 20px;
  background-color: green;
  border-radius: 10px;
  width: 100px;
  text-align: center;
}

.navlink {
  text-decoration: none;
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<div id="square">
  <ul>
    <li><a class="navlink" href="#">Introduction</a></li>
    <li><a class="navlink" href="#">Middle</a></li>
    <li><a class="navlink" href="#">End</a></li>
  </ul>
</div> …
Run Code Online (Sandbox Code Playgroud)

html css css3 centering

11
推荐指数
1
解决办法
384
查看次数

如何对数据框中每列的所有行求和

我有一个这样的 df :

         column A    column B    column C  .... ColumnZ 
 index
   X        1           4           7              10
   Y        2           5           8              11
   Z        3           6           9              12
Run Code Online (Sandbox Code Playgroud)

对于我的生活,我无法弄清楚如何对每列的行进行求和,以得出求和 df:

         column A    column B    column C  .... ColumnZ 
 index
 total       6           16          25             33
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

python dataframe pandas

7
推荐指数
2
解决办法
8298
查看次数

计算一个单词在n条推文中出现的次数

我的数据帧大约有118,000条推文。这是一个组成的样本:

Tweets
1 The apple is red
2 The grape is purple
3 The tree is green 
Run Code Online (Sandbox Code Playgroud)

我还使用了“设置”功能来获得在我的推文数据框中找到的每个唯一单词的列表。对于上面的示例,它看起来像这样(无特定顺序):

Words
1 The
2 is
3 apple
4 grape 
....so on
Run Code Online (Sandbox Code Playgroud)

基本上,我需要找出包含给定单词的推文数量。例如,在3条推文中找到“ The”,在1条推文中找到“ apple”,在3条推文中找到“ is”,依此类推。

我尝试过使用嵌套的for循环,如下所示:

number_words = [0]*len(words)
for i in range(len(words)):
    for j in range(len(tweets)):
        if words[i] in tweets[j]:
            number_words[i] += 1
number_words
Run Code Online (Sandbox Code Playgroud)

这将创建一个新列表,并为列表中的每个单词计算包含给定单词的推文数量。但是,我发现这种极其低效的代码块需要永远运行。

有什么更好的方法可以做到这一点?

python pandas

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

标签 统计

pandas ×2

python ×2

centering ×1

css ×1

css3 ×1

dataframe ×1

html ×1