小编Nik*_*eke的帖子

摘要不适用于OLS估算

我的statsmodels OLS估算有问题。该模型运行时没有任何问题,但是当我尝试调用摘要时,我可以看到实际结果,当a和权重的形状不同时,我需要指定轴的TypeError。

我的代码如下所示:

from __future__ import print_function, division 
import xlrd as xl
import numpy as np
import scipy as sp
import pandas as pd
import statsmodels.formula.api as smf
import statsmodels.api as sm

file_loc = "/Users/NiklasLindeke/Python/dataset_3.xlsx"
workbook = xl.open_workbook(file_loc)
sheet = workbook.sheet_by_index(0)
tot = sheet.nrows

data = [[sheet.cell_value(r, c) for c in range(sheet.ncols)] for r in range(sheet.nrows)]

rv1 = []
rv5 = []
rv22 = []
rv1fcast = []
T = []
price = []
time = []
retnor = [] …
Run Code Online (Sandbox Code Playgroud)

python finance linear-regression statsmodels

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

切换案例在React Native中不起作用

我对JS和RN比较陌生.但是我已经把自己困在了这个烂摊子里.

在React Native中,我试图调用徽章的渲染来描绘"Rank",这将根据调用将用于id的内容而改变.

为此,我在函数中调用一个带有Switch的js文件,这样根据我调用Rank的id,它将返回不同的.

我的代码目前看起来像这样:

'use strict';
import React, {
  StyleSheet,
  View,
  Text,
  ScrollView,
  Image,
  TouchableOpacity,
} from 'react-native';

var colors = require('../Styles/colorscheme');
import {Actions} from 'react-native-router-flux';

var id = this.id;
var Rank = React.createClass({
  render: function() {
    switch (id) {
      case 'smallone':
        return (
          <View style={styles.lvl2}>
            <Image source={require('../img/full_star_small@10x.png')} style={{padding: 10}} />
          </View>
          );
      case 'bigone':
        return (
          <View style={styles.lvl2}>
            <Image source={require('../img/full_star@10x.png')} style={{padding: 10}} />
          </View>
          );
      case 'smalltwo':
        return (
          <View style={styles.lvl2}>
            <Image source={require('../img/full_star_small@10x.png')} style={{padding: 10}} />
            <Image source={require('../img/full_star_small@10x.png')} …
Run Code Online (Sandbox Code Playgroud)

javascript switch-statement react-native

3
推荐指数
1
解决办法
2万
查看次数

React Native Fetch API不返回我的调用

对不起标题中的笑话.

我目前正在探索反应原生的fetch API,但我遇到了一些我无法解决的问题.

所以,我试图从服务器获取一条消息,我用以下方式使用fetch API调用它:

var serverCommunicator = {
    test: function() {
        fetch(baseUrl  , {
          method: 'GET',
          headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
          }
        })
        .then((response) => response.text())
        .then((responseText) => {
             return (JSON.stringify(responseText));
        })
        .catch((error) => {
          console.warn(error);
        }).done();
    },
module.exports = serverCommunicator;
Run Code Online (Sandbox Code Playgroud)

当我仅使用console.log(responseText)我的日志测试时给了我正确的消息.但是,现在当我想尝试将代码中的内容作为消息放入View中时,它不会按预期返回.以下列方式调用它:

import Method from '../Services/Methods';
.
.
.
<View style={styles.card}>
   <CardView
      message={Method.test()} 
    />
Run Code Online (Sandbox Code Playgroud)

我可以看到在调用它时如何正确调用函数测试,但由于某种原因,它不会编写消息.

javascript react-native fetch-api

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

检索 fbsdk 访问令牌和用户 ID 的问题

我正在尝试在我的 React Native 应用程序中检索登录用户的访问令牌和用户 ID。出于某种原因,当我尝试更新 fbsdkcore 包时,它不再存在。所以,我试图在通用的 fbsdk 包中解决它。

我将包中的 js 文件(我认为它检索访问令牌)称为:

const AccessToken = require('react-native-fbsdk/js/FBAccessToken');
Run Code Online (Sandbox Code Playgroud)

随后在我的代码中,我尝试记录它,以便我可以查看它是否有效,只需:

console.log(AccessToken.getCurrentAccessToken());
console.log(AccessToken.getUserId);
Run Code Online (Sandbox Code Playgroud)

但日志只返回:

2016-05-05 10:22:28.276 [info][tid:com.facebook.React.JavaScript] { _45: 0, _81: 0, _65: null, _54: null }
2016-05-05 10:22:28.277 [info][tid:com.facebook.React.JavaScript] undefined
Run Code Online (Sandbox Code Playgroud)

这似乎不是我要找的机器人。

我查看了 fbsdk 包中 js 文件的getCurrentAccessToken代码,代码如下:

  /**
   * Getter for the access token that is current for the application.
   */
  static getCurrentAccessToken(): Promise<?FBAccessToken> {
    return new Promise((resolve, reject) => {
      AccessToken.getCurrentAccessToken((tokenMap) => {
        if (tokenMap) {
          resolve(new FBAccessToken(tokenMap));
        } else { …
Run Code Online (Sandbox Code Playgroud)

javascript facebook react-native fbsdk

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