我正在使用 react native 构建一个应用程序,它要求我get request使用令牌在同一个 API 上执行多个操作。
假设网址是这样的
令牌 URL = https://test.co/v1/tokens、API URL 1 =https://test.co/v1/students和 API URL 2 =https://test.co/v1/cars
首先,为了从任一 API URL 获取数据,我是这样写的
示例 students_actions.js
import axios from 'axios';
import { FETCH_STUDENT } from './types';
const TOKEN_URL = '...'
const STUDENT_URL = '...'
export const fetchStudent = (callback) => async (dispatch) => {
axios.post(TOKEN_URL, {
email: 'email',
password: 'password',
role: 'user'
})
.then((response) => {
const accessToken = response.data.token;
//console.log(accessToken);
axios.get(STUDENT_URL, {
headers: { …Run Code Online (Sandbox Code Playgroud) 我下载了tesseract-OCR的可执行文件并安装了它.另一方面,我还从http://www.leptonica.com/download.html下载了leptonica的zip文件.它包括两个目录,即lib和include.
接下来我尝试pip install tesserocr在python virtualenvironment中做,它返回错误
tesserocr.cpp(460) : fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
Run Code Online (Sandbox Code Playgroud)
我注意到它allheaders.h是在include我之前下载的leptonica文件的目录中.我该如何解决这个问题?我应该把目录放在哪里include,lib我从leptonica那里得到这个工作?
有没有其他方法在Windows计算机上正确安装tesseract-ocr和使用tesserocr?目前我使用Windows 10运行我的python脚本,使用tesseract-ocr识别图像上的某些字符.我还计划稍后在Windows 7计算机上运行该脚本.
谢谢您的帮助.
如果标题有点令人困惑,请原谅我.
假设我有test.h5.以下是使用读取此文件的结果df.read_hdf('test.h5', 'testdata')
0 1 2 3 4 5 6
0 123 444 111 321 NaN NaN NaN
1 12 234 113 67 21 32 900
3 212 112 543 321 45 NaN NaN
Run Code Online (Sandbox Code Playgroud)
我想选择最后一个非Nan列.我的预期结果是这样的
0 321
1 900
2 45
Run Code Online (Sandbox Code Playgroud)
另外,我想选择除最后一个非NaN列之外的所有列.我的预期结果可能是这样的.它可能是numpy数组但我还没有任何解决方案.
0 1 2 3 4 5 6
0 123 444 111
1 12 234 113 67 21 32
3 212 112 543 321
Run Code Online (Sandbox Code Playgroud)
我在网上搜索,发现df.iloc[:, :-1]阅读所有专栏,但最后一篇,并df.iloc[:, -1]阅读最后一栏.
我使用这两个命令的当前结果如下:1.用于读取除最后一列之外的所有列
0 1 2 3 …Run Code Online (Sandbox Code Playgroud) 我最近一直在玩熊猫,现在我尝试用不同的正态分布随机值替换数据框中的NaN值。
假设我有这个没有标题的CSV文件
0
0 343
1 483
2 101
3 NaN
4 NaN
5 NaN
Run Code Online (Sandbox Code Playgroud)
我的预期结果应该是这样的
0
0 343
1 483
2 101
3 randomnumber1
4 randomnumber2
5 randomnumber3
Run Code Online (Sandbox Code Playgroud)
但是我得到了以下内容:
0
0 343
1 483
2 101
3 randomnumber1
4 randomnumber1
5 randomnumber1 # all NaN filled with same number
Run Code Online (Sandbox Code Playgroud)
到目前为止我的代码
import numpy as np
import pandas as pd
df = pd.read_csv("testfile.csv", header=None)
mu, sigma = df.mean(), df.std()
norm_dist = np.random.normal(mu, sigma, 1)
for i in norm_dist:
print df.fillna(i)
Run Code Online (Sandbox Code Playgroud)
我正在考虑从数据框中获取NaN行的数量,并用 …
我需要有关训练机器学习模型的准确性的帮助。
我的训练输入是几个包含 500 个整数/数据的数组,我将其保存在名为“the_data”的数据集下的 hdf5 文件中。在此示例中,我有 100 个数组。
[[1,2,3,...500],
[501,502,...1000],
[1001,... ],
....
...... ]]
Run Code Online (Sandbox Code Playgroud)
输出是我事先生成的随机数并将其保存为“output.txt”。它有 100 个随机数。
194521, 307329, 182440, 180444, 275690,...,350879
Run Code Online (Sandbox Code Playgroud)
下面是我基于http://machinelearningmastery.com/tutorial-first-neural-network-python-keras/修改的脚本
import h5py
from keras.models import Sequential
from keras.layers import Dense
seed = 7
np.random.seed(seed)
input_data = h5py.File('test.h5', 'r')
output_data = open("output.txt", "r")
X = input_data['the_data'][:]
Y = output_data.read().split(',')
model = Sequential()
model.add(Dense(500, input_dim=500, init='normal', activation='relu'))
model.add(Dense(100, init='normal', activation='relu'))
model.add(Dense(60, init='normal', activation='relu'))
model.add(Dense(1, init='normal', activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adamax', metrics=['accuracy'])
model.fit(X, Y, nb_epoch=500, batch_size=10)
scores = model.evaluate(X, Y) …Run Code Online (Sandbox Code Playgroud) 我一直在寻找这个答案,但并没有得到它.
我有一个看起来像这样的文本文件
who are you????
who are you man?
who are you!!!!
who are you? man or woman?
Run Code Online (Sandbox Code Playgroud)
我想跳过它的行man并打印
who are you????
who are you!!!!
Run Code Online (Sandbox Code Playgroud)
我的代码到目前为止
f = open("test.txt", "r")
word = "man"
for line in f:
if word in line:
f.next()
else:
print line
Run Code Online (Sandbox Code Playgroud)
这仅打印第一行
who are you????
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
谢谢您的帮助.
python ×5
pandas ×2
api ×1
dataframe ×1
javascript ×1
numpy ×1
random ×1
react-native ×1
react-redux ×1
redux-thunk ×1
tesseract ×1
windows-10 ×1