- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 hy 中执行以下操作:
from StringIO import StringIO
import pandas as pd
s = """sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
5 5.4 3.9 1.7 0.4 setosa
6 4.6 3.4 1.4 0.3 setosa
7 5.0 3.4 1.5 0.2 setosa
8 4.4 2.9 1.4 0.2 setosa
9 4.9 3.1 1.5 0.1 setosa"""
df = pd.read_table(StringIO(s), sep="\s+")
df.loc[df.sepal_length > 4.5]
(.loc df (> df.sepal_length 4.5))
最佳答案
有两种方法可以做到这一点:
.
macro :(. df loc [(> df.sepal-length 4.5)])
get
:(get df.loc (> df.sepal-length 4.5))
hy2py
在你的 Hy 文件上。它向您展示了生成的 Python 的样子。输出并不总是有效的语法,但它显示了编译成什么。这两个都被编译成
df.loc[(df.sepal_length > 4.5)]
.
sepal-length
. Hy 将标识符中的破折号转换为下划线,因此这与
sepal_length
相同,但它被认为是更好的风格。
关于pandas - 在 hy 中使用 pandas loc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33656372/
我了解如何使用hy.read_str和hy.eval从 python 评估 hy来自 python 内部的表达式。但是,当我使用这种方法时,导入和全局变量不会在 hy 之间共享。和python环境。考
我知道如何将 hy 模块导入到 python 中。我所要做的就是创建一个包含 hy 代码的 something.hy 文件,然后执行以下操作... import hy import something
如何将对象 HyExpression 打印为 HyExpression([ HyExpression([ HySymbol('/'), HyInteger(2)]),
我正在编写宏以简化使用 matplotlib 绘制绘图的过程。我的第一次尝试,如下所示,工作正常: (defmacro insert-ax [body] `((getattr g!ax (str '~
Hy 中指定元类的语法是什么。我尝试了以下方法: (defclass Metaclass [] ) (defclass Foo [ :meta Metaclass ] ) (defclass Foo
我查看了所有 Hy 的文档,但找不到在任何地方创建对象的方法。更具体地说,我正在尝试关注 this PySide tutorial ,但将每个命令转换为 Hy,我不确定如何在 Hy 中执行 app =
我想得到 Hy! 在 Hylang 中,我如何执行简单的 Python 循环: for i in range(5): print(i) 最佳答案 tutorial提供了这个例子: (for [
有什么方法可以用 Hy 中的索引替换列表或字典元素的值吗?nth 函数似乎不对应 Python 的方括号。 我期待的是下面的翻译。 (setv lst [1 2 3]) (setv (nth lst
我想在 hy 中执行以下操作: from StringIO import StringIO import pandas as pd s = """sepal_length sepal_width
在 python 中,以下代码迭代 numpy 数组(for 循环),并且 numpy 数组的值发生更改: import numpy a08_1 = numpy.arange(8).astype(nu
我想使用 Hy ,一种基于 Python 的 Lisp 方言。然而,我的同事都使用 Python,并且不太可能很快切换到 Lisp 方言。 如何将 Hy 代码打包到标准 Python 模块中? 最佳答
我在玩符号,惊讶地看到: hy 0.18.0 using CPython(default) 3.7.3 on Linux => (bool '0) False => (bool 'False) Tru
我已经从 https://github.com/hylang/hy-mode 成功安装了 hy-mode .我现在可以在 emacs 中打开 .hy 文件并进行语法高亮显示,并且使用 paredit
当我使用 -hy 标志来分析我的程序的堆使用情况时 ./prog +RTS -hy 经常看到构造函数*在结果中,以及其他构造函数,例如 []和 Word8 . 什么类型*在这种情况下?是否与kinds
我不明白为什么会出现这个错误 if (isset($_POST['submit'])) { require "../config.php"; require "../common.ph
我是一名优秀的程序员,十分优秀!