我写了一个小cython代码
#t3.pyx
from libc.stdlib cimport atoi
cdef int fun(char *s):
return atoi(s)
Run Code Online (Sandbox Code Playgroud)
该setup.py文件是
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize("t3.pyx"))
Run Code Online (Sandbox Code Playgroud)
我setup.py使用这个命令运行
python setup.py build_ext --inplace
Run Code Online (Sandbox Code Playgroud)
这给了我
Compiling t3.pyx because it changed.
Cythonizing t3.pyx
running build_ext
building 't3' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict- prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector- strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c t3.c -o build/temp.linux-x86_64-2.7/t3.o
t3.c:556:12: warning: ‘__pyx_f_2t3_fun’ defined but not used [-Wunused-function]
static int __pyx_f_2t3_fun(char *__pyx_v_s) …Run Code Online (Sandbox Code Playgroud) 我的(pandas)数据框中有一列:
data['Start Date'].head()
type(data['Start Date'])
Output:
1/7/13
1/7/13
1/7/13
16/7/13
16/7/13
<class 'pandas.core.series.Series'>
Run Code Online (Sandbox Code Playgroud)
当我将其转换为日期格式(如下所示)时,我收到错误ValueError:未知的字符串格式
data['Start Date']= pd.to_datetime(data['Start Date'],dayfirst=True)
...
...
/Library/Python/2.7/site-packages/pandas/tseries/tools.pyc in _convert_listlike(arg, box, format, name)
381 return DatetimeIndex._simple_new(values, name=name, tz=tz)
382 except (ValueError, TypeError):
--> 383 raise e
384
385 if arg is None:
ValueError: Unknown string format
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我无法找到有关seaborn热图的任何关键词的任何文件annot_kws或cbar_kws.
有一个秘密的地方我可以找到这样的东西吗?
所以我使用 miniconda 并尝试安装,pyperclip但conda-forge错误地我将名称大写,所以我运行:
conda install -c Conda-Forge pyperclip
(注意大写字母)。输出是:
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\USUARIO\miniconda3
added / updated specs:
- pyperclip
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2021.10.8 | h5b45459_0 176 KB Conda-Forge
certifi-2021.10.8 | py39hcbf5309_1 145 KB Conda-Forge
conda-4.11.0 | py39hcbf5309_0 16.8 MB Conda-Forge
openssl-1.1.1l | h8ffe710_0 5.7 MB Conda-Forge
pyperclip-1.8.2 | pyhd8ed1ab_2 14 KB Conda-Forge
------------------------------------------------------------
Total: 22.9 MB
The following …Run Code Online (Sandbox Code Playgroud) 我已经训练了一个模型scikit-learn使用Cross-Validation和Naive Bayes分类器中.如何坚持使用此模型以便以后针对新实例运行?
这就是我所拥有的,我能得到的 CV分数,但我不知道如何访问训练有素的模型
gnb = GaussianNB()
scores = cross_validation.cross_val_score(gnb, data_numpy[0],data_numpy[1], cv=10)
Run Code Online (Sandbox Code Playgroud) 我需要qtanaconda中5.12版本的包,但是安装了5.9.7版本。
>>> conda list qt -f
# packages in environment at /PATH/anaconda3/env/my_env
#
# Name Version Build Channel
qt 5.9.7 h5867ecd_1
Run Code Online (Sandbox Code Playgroud)
qt由于默认通道中的最新版本anaconda是 5.9.7( https://anaconda.org/anaconda/qt ),因此我想qt从通道安装软件包conda-forge,该通道的版本为 5.12.5( https://anaconda.qt )。 org/conda-forge/qt)。
qt所以我尝试使用此命令从conda-forge频道安装。
>>> conda install qt -c conda-forge --override-channels
Run Code Online (Sandbox Code Playgroud)
但 conda 没有qt从新通道安装,并打印出所有软件包已安装。
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Run Code Online (Sandbox Code Playgroud)
仅供参考,我在 .condarc 中的通道配置是
channels:
- defaults
- conda-forge
channel_priority: disabled
Run Code Online (Sandbox Code Playgroud)
为什么 …
我安装了anaconda发行版,我通常运行ipython notebook --pylab inline.我更新了ipython使用pip install(Windows 8.1),我不必编写--pylab内联启动了
我开始在单元格中写道:%matplotlib nbagg或者matplotlib.use['nbagg'],但是当我绘制一些东西时,它显示了这个空盒子:

我期待着交互式绘图框.
ipython日志显示:
[IPKernelApp] ERROR | No such comm: 7cfe982045bb4d0db0f14deff7258130
Run Code Online (Sandbox Code Playgroud) 我想在直方图中添加密度图.我对pdf函数有所了解,但我感到困惑,其他类似的问题也无济于事.
from scipy.stats import *
from numpy import*
from matplotlib.pyplot import*
from random import*
nums = []
N = 100
for i in range(N):
a = randint(0,9)
nums.append(a)
bars= [0,1,2,3,4,5,6,7,8,9]
alpha, loc, beta=5, 100, 22
hist(nums,normed= True,bins = bars)
show()
Run Code Online (Sandbox Code Playgroud)
我正在寻找这样的东西
我有两个日期时间列,当我将它们读入内存但实际上在美国/东部时它们是天真的.我只想将这两列转换为US/Central.
我发现了一种有效的方法,但似乎我正在做一个解决方法.我将call_start和call_end列改为名为'start'和'end',因此我最终没有重复的列名.然后,我为每个列创建了一个单独的datetimeindex并重置索引.
aht.set_index(pd.DatetimeIndex(aht['start']).tz_localize('US/Eastern').tz_convert('US/Central'), inplace = True, drop = True)
aht.index.names = ['call_start']
aht = aht.reset_index()
aht.set_index(pd.DatetimeIndex(aht['end']).tz_localize('US/Eastern').tz_convert('US/Central'), inplace = True, drop = True)
aht.index.names = ['call_end']
aht = aht.reset_index()
Run Code Online (Sandbox Code Playgroud)
我最终得到:
call_end call_start start end
2016-01-13 06:05:01-06:00 2016-01-13 06:02:00-06:00 01/13/2016 07:02 01/13/2016 07:05
2016-01-13 06:07:00-06:00 2016-01-13 06:03:16-06:00 01/13/2016 07:03 01/13/2016 07:07
2016-01-13 06:09:13-06:00 2016-01-13 06:06:02-06:00 01/13/2016 07:06 01/13/2016 07:09
2016-01-13 06:17:51-06:00 2016-01-13 06:06:20-06:00 01/13/2016 07:06 01/13/2016 07:17
Run Code Online (Sandbox Code Playgroud)
这是最好的方法吗?所有其他数据都在中央时间,所以我只是想确保这个文件太合并,当我将文件合并在一起时更有意义.我不关心那里有实际的时区标记 - 有没有办法在我创建新列后轻松剥离它?
看看关于DataFrame的to_json方法的pandas文档,这个orient论点含糊不清.它接受的参数类型是字符串,而不是字典.然而,似乎它实际上有三件事可以接受并且每个都有它们自己的默认值:Series(默认'index'),DataFrame(默认'columns')和"JSON字符串的格式"(无默认值).
我想知道orient参数的可接受值是什么以及它们对输出json的作用.
python ×9
pandas ×3
anaconda ×2
conda ×2
conda-forge ×2
matplotlib ×2
cython ×1
ipython ×1
jupyter ×1
pickle ×1
python-3.x ×1
scikit-learn ×1
seaborn ×1