小编MB4*_*B41的帖子

pickerView显示为问号而不是数据?

我正在尝试向我的iphone应用程序添加一个pickerview,但不是显示我的数组中的字符串,而是显示问号.有谁知道为什么?我一直试图弄清楚过去一小时......这是我的控制器代码,包含了pickerview:

class NewIssueViewController: UIViewController, UIPickerViewDelegate {

    var componentArr = ["component1","component2","component3","component4"]

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.


    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func CancelPressed(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    @IBAction func AddPressed(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    func numberOfComponentsInPickerView(pickerView: UIPickerView!) -> Int {
        return 1
    }

    func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) -> Int {
        return componentArr.count
    }

    func …
Run Code Online (Sandbox Code Playgroud)

iphone swift xcode6

8
推荐指数
1
解决办法
4061
查看次数

如何在数据框中添加新的计算列?

我正在尝试从我拥有的数据中计算一个人的年龄:

Data columns in 'Person' Dataframe:
TodaysDate   non-null datetime64[ns]
YOB          non-null float64
Run Code Online (Sandbox Code Playgroud)

所以我想在该数据框中创建一个名为'Age'的新列,到目前为止,我有以下代码:

Person['Age'] = map(sum, (Person.ix[0,'TodaysDate']).year, -(Person['YOB']))

TypeError: 'int' object is not iterable
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

Person['Age'] = map((Person.ix[0,'TodaysDate']).year - Person['YOB'])

TypeError: map() must have at least two arguments.
Run Code Online (Sandbox Code Playgroud)

我尝试了一些不同的方法,这些方法已经发布在其他问题上,但似乎都没有.这看起来很简单......但无法让它发挥作用.

有什么想法我如何使用map函数TodaysDate从float列中减去datetime列YOB并将值放入Age列中?我想对数据帧中的每一行执行此操作.

谢谢!

python pandas

5
推荐指数
2
解决办法
7055
查看次数

为什么我的if语句跳过了else?

我正在写一个计算代码行的小程序.以下是一行代码的定义: - 包含程序运行所需代码的任何行. - 空白行不是一行代码. - 评论不是一行代码. - 如果在同一行之后有代码和注释,那么它也很重要.

所以我有这段代码(简单的if语句):

found = lineRead.find("/*");
if(found != string::npos)
{
    found = lineRead.find("*/");
    if(found != string::npos)
        inComment = false;
    else
        inComment == true;
}
return inComment;
Run Code Online (Sandbox Code Playgroud)

假使,假设

String lineRead = "cout<<\"helloworld!\";/*blockcomment"
Bool inComment (is true if the previous line didn't have end block comment token)
Run Code Online (Sandbox Code Playgroud)

所以我的程序到达第一个if语句,因为它/*在那一行找到,查找*/,转到第二个if语句然后直接跳转到return语句而不改变inComment(应该设置为true因为下一行的文本仍然是在块内注释).

谁知道为什么会这样?

c++ string if-statement counting

1
推荐指数
1
解决办法
1312
查看次数

标签 统计

c++ ×1

counting ×1

if-statement ×1

iphone ×1

pandas ×1

python ×1

string ×1

swift ×1

xcode6 ×1