默认情况下,当前行总是在geany文本编辑器中突出显示.我们如何禁用此功能?
相关链接是:
http://comments.gmane.org/gmane.editors.geany.general/3765
如何突出geany中的多行代码块
任何帮助将不胜感激!
Geany是一个简单,快速但功能强大的文本编辑器.它几乎支持几乎所有类型的编程语言的语法突出显示.
我想知道如何为我的特殊需求程序高亮显示一个名为"Phosim"的文件扩展名.cat.
到目前为止,我已经这样做了:
首先我创建了filetype扩展配置文件:~/.config/geany/filetype_extensions.conf
其内容如下所示:
[Extensions]
Gnuplot=*.gp;*.gnu;*.plt;
Galfit=*.gal;
Phosim=*.cat;
[Groups]
Script=Gnuplot;Galfit;Phosim;
Run Code Online (Sandbox Code Playgroud)
在这里,我正在尝试将自定义高亮应用于程序Gnuplot,Galfit和Phosim.对于Gnuplot和Galfit,它工作得很好.但是对于Phosim我遇到了一些问题.
然后我创建了文件定义配置文件:~/.config/geany/filedefs/filetypes.Phosim.conf
其内容如下所示:
# Author : Bhishan Poudel
# Date : May 24, 2016
# Version : 1.0
[styling]
# Edit these in the colorscheme .conf file instead
default=default
comment=comment_line
function=keyword_1
variable=string_1,bold
label=label
userdefined=string_2
number=number_2
[keywords]
# all items must be in one line separated by space
variables=object Unrefracted_RA_deg SIM_SEED none
functions=
lables=10
userdefined=angle 30 Angle_RA 20.0 none
numbers=0 1 2 3 4 5 …Run Code Online (Sandbox Code Playgroud) 问题:我在MacOs 10.9中使用pip3安装了python3和jupyter笔记本。
当我尝试运行窗口小部件时,出现错误,提示没有javascript小部件。我在Jupyter-notebook中安装了python3和R内核。
码:
from ipywidgets import widgets
from IPython.display import display
text = widgets.Text()
display(text)
text.on_submit('hello')
Run Code Online (Sandbox Code Playgroud)
错误:
Widget Javascript not detected. It may not be installed or enabled properly.
Run Code Online (Sandbox Code Playgroud)
尝试次数:
sudo -H pip3 install ipywidgets
sudo -H pip3 install -upgrade ipywidgets
jupyter nbextension enable --py widgetsnbextension
# restarted the computer.
Run Code Online (Sandbox Code Playgroud)
最后一条命令给出错误。
[EnableNBExtensionApp] CRITICAL | Bad config encountered during initialization:
[EnableNBExtensionApp] CRITICAL | Unrecognized flag: '--py'
Run Code Online (Sandbox Code Playgroud)
请注意,在Mac中,我有jupyter-nbextension命令,但该命令为:
jupyter-nbextension enable --py widgetsnbextension
Run Code Online (Sandbox Code Playgroud)
也不起作用。
但是jupyter nbextension enable widgetsnbextension没有错误,也没有任何作用。如果运行代码,则会弹出相同的错误。
也,
import …Run Code Online (Sandbox Code Playgroud) 我们可以在 jupyter-notebook 和 jupyter-lab 单元中使用 sublime 风格的键盘快捷键吗?
** 示例要求:**
cmd shift up 将 jupyter 单元格中的行向上移动
注意: 我正在使用 conda 环境使用 jupyter-lab。
我的尝试:
在 jupyter-lab 中,我将文本编辑器更改为 sublime,它仅适用于文本编辑器,不适用于 jupyter 单元格。
我关注了这个博客:http : //blog.rtwilson.com/how-to-get-sublime-text-style-editing-in-the-ipythonjupyter-notebook/
~/.jupyter/custom/custom.js~/miniconda3/lib/python3.6/site-packages/notebook/static/custom/custom.jscmd-shift-up/down 选择 line 和 above line,不移动它们。
这在 jupyter-cell 中也不起作用。
http://blog.rtwilson.com/how-to-get-sublime-text-style-editing-in-the-ipythonjupyter-notebook/

我试图通过向下转换浮点数据类型来减少内存消耗。
\n\n我检查了范围np.float16:
np.finfo(np.float16)\nfinfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04, dtype=float16)\nRun Code Online (Sandbox Code Playgroud)\n\n由此可见-6.55040e+04 < 2053 < 6.55040e+04
现在:
\n\nnp.finfo(np.float16)\nfinfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04, dtype=float16)\nRun Code Online (Sandbox Code Playgroud)\n\n为什么会这样呢?
\n\n更新
\n借用文档np.finfo
numpy.finfo\nclass numpy.finfo[source]\nMachine limits for floating point types.\n\nParameters: \ndtype : float, dtype, or instance\n\nKind of floating point data-type about which to get information.\n\nAttributes\n\neps (float) The smallest representable positive number such that 1.0 + eps != 1.0. Type of eps is an appropriate floating point type.\nepsneg (floating point number of the …Run Code Online (Sandbox Code Playgroud) 最近我发现了 Python 可视化库“Facets”,想知道是否可以离线生成 html 输出。
webcomponents-lite.js不需要。~/.ipython/nbextensions/有用的链接:
- https://github.com/PAIR-code/facets
- https://colab.research.google.com/github/PAIR-code/facets/blob/master/colab_facets.ipynb
import numpy as np
import pandas as pd
from IPython.core.display import display, HTML
df = pd.DataFrame({'a':[10,20],'b':[100,200]})
jsonstr = df.to_json(orient='records')
HTML_TEMPLATE = """<link rel="import" href="/nbextensions/facets-dist/facets-jupyter.html">
<facets-dive id="elem" height="600"></facets-dive>
<script>
var data = {jsonstr};
document.querySelector("#elem").data = data;
</script>"""
html_str = HTML_TEMPLATE.format(jsonstr=jsonstr)
# write the html to a file
with open('output.html', 'w') as f:
f.write(html_str)
#f.write(HTML(html_str).data)
!open …Run Code Online (Sandbox Code Playgroud) 我正在学习pyspark哪些用途,HiveQL并发现百分比排名为pyspark-sql和给出了两个不同的答案,这很有趣pandas。
带有sql代码的问题来源:https : //www.windowfunctions.com/questions/ranking/3
如何在 Pandas 中获得与 SQL 相同的结果?
q = """
select name, weight,
percent_rank() over (order by weight) as percent_rank_wt
from cats
order by weight
"""
spark.sql(q).show()
SQL gives this table. I would like same table using pandas.
+-------+------+-------------------+
| name|weight| percent_rank_wt|
+-------+------+-------------------+
| Tigger| 3.8| 0.0|
| Molly| 4.2|0.09090909090909091|
| Ashes| 4.5|0.18181818181818182|
|Charlie| 4.8| 0.2727272727272727|
| …Run Code Online (Sandbox Code Playgroud) 我有一个这样的数据框:
id type city
0 2 d H
1 7 c J
2 7 x Y
3 2 o G
4 6 i F
5 5 b E
6 6 v G
7 8 u L
8 1 g L
9 8 k U
Run Code Online (Sandbox Code Playgroud)
我想使用 Pandas 获得与 SQL 命令中类似的输出:
select id,type
from df
order by type desc
limit 4
offset 2
Run Code Online (Sandbox Code Playgroud)
需要的结果是:
id type
0 8 u
1 2 o
2 8 k
3 6 i
Run Code Online (Sandbox Code Playgroud)
我试图按照官方教程https://pandas.pydata.org/pandas-docs/stable/comparison_with_sql.html#top-n-rows-with-offset
df.nlargest(4+2, columns='type').tail(4) …Run Code Online (Sandbox Code Playgroud) 我知道我们可以使用 pandas dataframe 过滤器仅选择几列,但是我们也可以仅排除某些列吗?
这是 MWE:
import numpy as np
import pandas as pd
df = pd.DataFrame({'id': [1,2,3], 'num_1': [10,20,30], 'num_2': [20,30,40]})
df.filter(regex='num')
Run Code Online (Sandbox Code Playgroud)
我们可以选择列中没有“num”的所有列吗:
就像是:
df.filter(regex='^(num)')
Run Code Online (Sandbox Code Playgroud)
所需输出
id
0 1
1 2
2 3
Run Code Online (Sandbox Code Playgroud)
笔记
# these already works, i am only looking regex way
df[['id']] # gives the required output
Run Code Online (Sandbox Code Playgroud)
参考:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.filter.html
我已经看到很多使用 pandas 在 stackoverflow 中读取 json 的问题,但我仍然无法解决这个简单的问题。
{"session_id":{"0":["X061RFWB06K9V"],"1":["5AZ2X2A9BHH5U"]},"unix_timestamp":{"0":[1442503708],"1":[1441353991]},"cities":{"0":["New York NY, Newark NJ"],"1":["New York NY, Jersey City NJ, Philadelphia PA"]},"user":{"0":[[{"user_id":2024,"joining_date":"2015-03-22","country":"UK"}]],"1":[[{"user_id":2853,"joining_date":"2015-03-28","country":"DE"}]]}}
Run Code Online (Sandbox Code Playgroud)
import numpy as np
import pandas as pd
import json
from pandas.io.json import json_normalize
# attempt1
df = pd.read_json('a.json')
# attempt2
with open('a.json') as fi:
data = json.load(fi)
df = json_normalize(data,record_path='user',meta=['session_id','unix_timestamp','cities'])
Both of them do not give me the required output.
Run Code Online (Sandbox Code Playgroud)
session_id unix_timestamp cities user_id joining_date country
0 X061RFWB06K9V 1442503708 New York NY 2024 2015-03-22 UK
0 X061RFWB06K9V …Run Code Online (Sandbox Code Playgroud) python ×7
pandas ×5
geany ×2
dataframe ×1
facet ×1
highlight ×1
hiveql ×1
javascript ×1
json ×1
jupyter ×1
jupyter-lab ×1
numpy ×1
pyspark ×1
sql ×1
sublimetext3 ×1
text-editor ×1