我正在尝试在我的Mac上安装Jupyter(OS X El Capitan),我收到错误以回应:
sudo pip install -U jupyter
Run Code Online (Sandbox Code Playgroud)
首先下载/安装开始很好,但后来我遇到这个:
Installing collected packages: six, singledispatch, certifi, backports-abc, tornado, jupyter-core, pyzmq, jupyter-client, functools32, jsonschema, nbformat, pygments, mistune, MarkupSafe, jinja2, nbconvert, path.py, pickleshare, simplegeneric, setuptools, gnureadline, appnope, ptyprocess, pexpect, ipython, ipykernel, terminado, notebook, ipywidgets, jupyter-console, qtconsole, jupyter
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will …Run Code Online (Sandbox Code Playgroud) 我想知道这样的声明:
let queue = DispatchQueue(label: "com.example.imagetransform")
Run Code Online (Sandbox Code Playgroud)
我正在用Swift 3观看WWDC并发性,并且演示者在上面提到,队列的标签显示在调试器中。除此以外,我想知道该名称对于引用该队列是否有意义或有用,或者这些队列是否遵循与其他类型的数据结构相同的作用域规则(因此队列声明仅在其作用域内有意义)。
即使队列声明仅在其范围内有意义,如果执行此操作会怎样?
let queue1 = DispatchQueue(label: "com.example.imagetransform")
let queue2 = DispatchQueue(label: "com.example.imagetransform")
Run Code Online (Sandbox Code Playgroud)
这些队列实际上是否相同,所以如果我先说向队列1添加一个作业,然后向队列2添加一个作业,那么队列2的作业实际上与队列1的作业在同一行?
我正在寻找一种智能方法,以智能方式从HealthKit导入所有时间的所有数据,适用于大量用户,他们每天数百次记录某些HealthKit值数月或数年.我也希望在主线程中做到这一点,并且用户可以随时关闭应用程序这样的事实.这是我目前的实现:
- (void) fullHealthKitSyncFromEarliestDate {
dispatch_queue_t serialQueue = dispatch_queue_create("com.blah.queue", DISPATCH_QUEUE_SERIAL);
NSLog(@"fullHealthKitSyncFromEarliestDate");
NSDate *latestDate = [PFUser currentUser][@"earliestHKDate"];
if (!latestDate) latestDate = [NSDate date];
NSDate *earliestDate = [healthStore earliestPermittedSampleDate];
NSLog(@"earliest date %@ and latest date %@", earliestDate, latestDate);
if ([earliestDate earlierDate:[[NSDate date] dateByAddingYears:-2]] == earliestDate) {
earliestDate = [[NSDate date] dateByAddingYears:-1];
}
__block NSDate *laterDate = latestDate;
__block NSDate *earlierDate = [latestDate dateByAddingMonths:-1];
int i = 0;
while ([earlierDate earlierDate:earliestDate] == earliestDate) {
// DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(i * 30 * NSEC_PER_SEC)), serialQueue, …Run Code Online (Sandbox Code Playgroud) 我是使用 Bokeh 的第一天,我正在尝试了解服务器的工作原理。首先,我运行了一个示例应用程序
bokeh serve --show main.py
Run Code Online (Sandbox Code Playgroud)
我看到了这个信息:
然后我看到没有其他未使用的会话可用,因此当我尝试并行运行另一个应用程序(使用相同命令从另一个窗口启动)并且失败时,我并不完全感到惊讶:
所以我想如果我关闭应用程序窗口,我将能够运行另一个应用程序,并且我注意到服务器确实注册了我关闭了网络浏览器:
但是我仍然收到此错误:
port 5006 is already in use
Run Code Online (Sandbox Code Playgroud)
我浏览了文档,如果我遗漏了一些东西,我很抱歉,但我的两个问题是
感谢您的建议和链接。
我正在尝试对常用的航空公司乘客数据集运行基本的seasonal_decompose,该数据集以这些行开头:
Month
1949-02 4.770685
1949-03 4.882802
1949-04 4.859812
1949-05 4.795791
1949-06 4.905275
1949-07 4.997212
1949-08 4.997212
1949-09 4.912655
1949-10 4.779123
1949-11 4.644391
1949-12 4.770685
1950-01 4.744932
1950-02 4.836282
1950-03 4.948760
1950-04 4.905275
1950-05 4.828314
1950-06 5.003946
1950-07 5.135798
1950-08 5.135798
Freq: M, Name: Passengers, dtype: float64
Run Code Online (Sandbox Code Playgroud)
我的索引类型是:
pandas.tseries.period.PeriodIndex
Run Code Online (Sandbox Code Playgroud)
我尝试运行一些非常简单的代码:
from statsmodels.tsa.seasonal import seasonal_decompose
log_passengers.interpolate(inplace = True)
decomposition = seasonal_decompose(log_passengers)
Run Code Online (Sandbox Code Playgroud)
这是错误的完整输出:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-113-bf122d457673> in <module>()
1 from statsmodels.tsa.seasonal import seasonal_decompose
2 log_passengers.interpolate(inplace = True)
----> …Run Code Online (Sandbox Code Playgroud) 我有一个最初定义为接受NSString参数的方法,但现在需要能够接受一个NSString参数或一个NSAttributedString参数。不幸的是,它们不共享继承层次结构,但每个都继承自NSObject. 为此,我修改了该方法以获取NSObject然后检查方法体内参数的类。
这正如我所愿。但是,现在我从一些调用该方法的快速代码中收到编译器错误:
Cannot convert value of String 'String' to expected argument type 'NSObject!'
我才刚刚开始使用 Swift,这个特定的代码是由其他人编写的。我尝试用 包围方法调用中的字符串,NSObject(...)但这不起作用。适应这种情况的最佳方法是什么?
我在应用程序中加入了新的数据加载功能。它旨在将大型数据库的内容从移动设备传输并处理到后端。在我在此管道中运行的函数中,函数的全部内容都在
dispatch_async
Run Code Online (Sandbox Code Playgroud)
这将分派到非主线程。我还用日志验证了它们是否有效。管道中的每个函数都不在主线程上。但是我遇到UI冻结的问题。
问题:
我有一个从 csv 中读取的相当大的 Pandas DataFrame(约 300 万行和 72 列),并且我收到警告说某些列包含混合数据类型:
DtypeWarning: Columns (1,2,3,15,16,17,18,19,20,21,22,23,31,32,33,35,37,38,39,40,41,42,43,44,45,46,47,48,50,51,52,55,57,58,60,71) have mixed types. Specify dtype option on import or set low_memory=False.
interactivity=interactivity, compiler=compiler, result=result)
Run Code Online (Sandbox Code Playgroud)
鉴于我不能只关注 csv,处理这个问题的最佳方法是什么?特别是,有没有办法获取给定列中出现的所有数据类型的列表以及它们对应的行号是什么?
我正在查看一个如下所示的电子邮件发件人数据列:
from_name
----------
Joe Smith, VP at Corp
Alice Brown
None
Helpdesk, McRay's Store
Run Code Online (Sandbox Code Playgroud)
从这里,我想生成一个这样的列:
title_if_any
-------------
VP at Corp
None
None
McRay's Store
Run Code Online (Sandbox Code Playgroud)
我尝试过以下方法:
email_data['title_email_sender'] = email_data[email_data.from_name.isnull() == False][email_data.from_name.apply(lambda x: ',' in x)].from_name.apply(lambda x: x.split(',')[1])
Run Code Online (Sandbox Code Playgroud)
但是这会产生以下错误:
----> 2 email_data['title_email_sender'] = email_data[email_data.from_name.isnull() == False][email_data.from_name.apply(lambda x: ',' in x)].from_name.apply(lambda x: x.split(',')[1])
TypeError: argument of type 'NoneType' is not iterable
Run Code Online (Sandbox Code Playgroud)
我的第一个选择不应该删除所有NoneTypes吗?我怎样才能实现我想要的并解决上述问题?
谢谢!
这是我所得到的:
do {
try let jsonData: NSData = NSJSONSerialization.dataWithJSONObject(paramsDict, options: NSJSONWritingOptions.PrettyPrinted)
jsonString = NSString(data: jsonData, encoding: NSUTF8StringEncoding)! as String
} catch {
print("CAUGHT SOMETHING session token")
}
Run Code Online (Sandbox Code Playgroud)
我收到错误try must be placed on the initial value expression。我尝试像这样“改写”:
do {
let jsonData: NSData = NSJSONSerialization.dataWithJSONObject(paramsDict, options: NSJSONWritingOptions.PrettyPrinted)
try jsonString = NSString(data: jsonData, encoding: NSUTF8StringEncoding)! as String
} catch {
print("CAUGHT SOMETHING session token")
}
Run Code Online (Sandbox Code Playgroud)
但这会导致错误Call can throw but is not marked with 'try'。我应该如何构造这个 try-catch 以及这些错误代码的含义是什么?
python ×5
ios ×3
objective-c ×3
pandas ×3
swift ×3
bokeh ×1
concurrency ×1
dataframe ×1
healthkit ×1
jupyter ×1
macos ×1
nsobject ×1
statsmodels ×1
try-catch ×1