我正在尝试ctypes使用Python 2.7.4在Mac OS X 10.6.8上访问Python中的共享C库.要做到这一点,我需要#include <Python.h>在我的C代码中.如果我尝试编译一个只有一个include语句的C脚本,请将其命名为"sample.c",我得到:
$ gcc -shared -o sample.so sample.c
sample.c:1:20: error: Python.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
由于我运行的是Mac 10.6,我有Xcode 3.2.6,这是OS X迭代的最新版本,无需支付升级到10.7并获得Xcode 4.有没有办法在不升级我的操作系统的情况下获取Python头文件?
如何检测一个轴是否有一个双轴写在它上面?例如,如果在ax下面给出,我如何发现它ax2存在?
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
ax2 = ax.twinx()
Run Code Online (Sandbox Code Playgroud) I have a pandas dataframe containing string values and a datetime index, like so:
from datetime import datetime as dt
import pandas as pd
df = pd.DataFrame(['a', 'b', 'b', 'c', 'b', 'b', 'b'],
[dt(2019, 1, 1), dt(2019, 1, 2),
dt(2019, 1, 3), dt(2019, 1, 4),
dt(2019, 1, 5), dt(2019, 1, 6),
dt(2019, 1, 7)])
Run Code Online (Sandbox Code Playgroud)
If I wanted to compute the number of instances that each value occurs over all times, I can simply call:
>>> print(df[0].value_counts())
b 5
c 1 …Run Code Online (Sandbox Code Playgroud)