我正在尝试使用我的 pymongo 和临时数据库做一些简单的事情。所以第一件事和往常一样
import pymongo
connection = pymongo.Connection(host = 'mongodb://username:password@alaki-staging.member0.mongolayer.com:37017,/dbname?safe=true&slaveOk=true&fsync=true&journal=true&ssl=true')
Run Code Online (Sandbox Code Playgroud)
现在只是
connection.find({})
> Traceback (most recent call last):
File "D:\MypythonCode\test.py", line 7, in <module>
connection.find({})
File "C:\Python27\lib\site-packages\pymongo\database.py", line 769, in __call_
_
self.__name, self.__connection.__class__.__name__))
TypeError: 'Database' object is not callable. If you meant to call the 'find' me
thod on a 'Connection' object it is failing because no such method exists.
C:\Python27>python.exe D:\MypythonCode\test.py > test.d
Traceback (most recent call last):
File "D:\MypythonCode\test.py", line 7, in <module>
connection.find({})
File "C:\Python27\lib\site-packages\pymongo\database.py", line …Run Code Online (Sandbox Code Playgroud) 我有一个很大的文本文件,我想只提取某些短语/单词后面的数字。
这个巨大的文本文件中有几十行,格式如下:
汽车的最佳 CV 模型:15778 的顺序:2 阈值:0,AUC 为:0.7185 基因 aau_roc:0.466281
一种解决方案是只查看“for car: X”、“is order: X”、“threshold: X”、“Ygene aau_roc: X”之后的数字!
最后我希望每行有 15778, 2, 0, 0.7185, 0.466281。
我想在我的图像图中使用我自己的特定颜色。我是 ggplot2 的新手,所以从这里查看了它的手册并尝试重复一些内容;但我不知道如何提供我的颜色条,就像我为图形绘图所做的那样。
library(reshape2)
library(ggplot2)
#my specific color list
mycol <- vector(length=512, mode = "numeric")
for (k in 1:256) mycol[k] <- rgb(255, k - 1, k - 1, maxColorValue=255)
for (k in 257:512) mycol[k] <- rgb(511 - (k - 1), 511 - (k - 1), 255, maxColorValue=255)
mycol <- rev(mycol)
ncolors <- length(mycol)
# graphics plot
par(mar = c(5, 13, 1, 6))
image(1:ncol(volcano), 1:nrow(volcano), t(volcano), zlim = c(0, ncolors), col=mycol, axes=FALSE, main="W Matrix", sub = "", xlab= "Components", …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个仪表板,其中说明了 shap forceplot 的输出。 Shap.forceplot是用 json 装饰的 HTML。例子在这里
我使用教程制作了一个非常简单的仪表板,它应该在单击提交后绘制所需的图形
这是代码
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import pandas as pd
from sqlalchemy import create_engine
import shap
from sources import *
import xgboost
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
dcc.Input(id='input-cvr-state', type='text', value='12'),
html.Button(id='submit-button', n_clicks=0, children='Submit'),
html.Div(id='output-state'),
html.Div(id='output-shap')
])
@app.callback(Output('output-shap', 'children'),
[Input('submit-button', 'n_clicks')],
[State('input-cvr-state', 'value')])
def update_shap_figure(n_clicks, input_cvr):
shap.initjs()
# train …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 google-speech2text api 但是,即使我已将代码设置为通过所有可用的编码器,我仍然不断收到“指定 MP3 编码以匹配音频文件”。
这是我正在尝试使用的文件
我必须补充一点,如果我将文件上传到他们的 UI 上,我可以获得输出。所以我假设源文件中没有任何问题。
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
client = speech.SpeechClient.from_service_account_json('gcp_credentials.json')
speech_file = 'chunk7.mp3'
import io
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
with io.open(speech_file, 'rb') as audio_file:
content = audio_file.read()
audio = types.RecognitionAudio(content=content)
import wave
ENCODING = [enums.RecognitionConfig.AudioEncoding.LINEAR16,
enums.RecognitionConfig.AudioEncoding.FLAC,
enums.RecognitionConfig.AudioEncoding.MULAW,
enums.RecognitionConfig.AudioEncoding.AMR,
enums.RecognitionConfig.AudioEncoding.AMR_WB,
enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
enums.RecognitionConfig.AudioEncoding.SPEEX_WITH_HEADER_BYTE]
SAMPLE_RATE_HERTZ = [8000, 12000, 16000, 24000, 48000]
for enco in ENCODING:
for rate …Run Code Online (Sandbox Code Playgroud) 我知道这里还有其他关于此问题的帖子,但我仍在努力寻找正确的解决方案。我正在尝试使用以下 python 脚本下载 S3 存储桶(我有权访问)中的一组特定对象。运行脚本时,第一个对象成功下载,但随后抛出此错误 (403):
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
Run Code Online (Sandbox Code Playgroud)
请参阅下面我的代码:
import csv
import boto3
import re
import logging
from botocore.exceptions import ClientError
prod_number_array_bq = []
prod_number_array_s3 = []
with open('bq-results-20191218-151637-rshujisvqrri.csv') as csv_file:
csv_reader = csv.reader(csv_file,delimiter=',')
line_count = 0
for row in csv_reader:
sliced = re.sub("[^0-9]", "", str(row))
prod_number_array_bq.append(sliced)
s3 = boto3.resource('s3')
bucket = s3.Bucket('********')
for key in bucket.objects.all():
sliced = re.sub("[^0-9]", "", str(key.key))
if((set(sliced) & set(prod_number_array_bq))!=""):
bucket.download_file(key.key,sliced + '.txt')
Run Code Online (Sandbox Code Playgroud)
如有帮助,将不胜感激:)
谢谢
它对我来说超级迷茫,因为pdfmaker和postscript都是一样的,但在实践中编码风格却截然不同.
我知道如何使用Postscript语言中的moveto和lineto以及arc命令在其末尾创建一个2行的行,但是,由于超链接,显然我必须转移到pdfmark,pdfmark手册是超级不可理解的,并且没有其他参考书(书/在线教程).
所以,我会很感激,如果有人可以用一点描述产生这样的东西(如我的图所示).

我想用不同颜色的句子上色 - 比如,前半部分用红色,用蓝色休息.
到目前为止,我的代码就像
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import ColorFormat, RGBColor
from pptx.enum.dml import MSO_COLOR_TYPE, MSO_THEME_COLOR
import codecs
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
text_file = open("content.txt", "r")
# read the lyrics file
lines = text_file.readlines()
# page title
title = slide.shapes.title
# text frame in the page
tf = title.textframe
# paragrap in the text frame
p = tf.add_paragraph()
# write the first sentence
#p.text = unicode(lines[0], encoding='utf-8')
p.text …Run Code Online (Sandbox Code Playgroud) 我已经遵循了这个问题的每一步
安装 venv: python3 -m venv venv. 将install_venv.sh(位于下载的文件夹中)文件拖到终端,-p在末尾添加。选择venv的目录作为tensorflow的安装位置。激活 venv。输入“蟒蛇”。
尝试导入张量流:import tensorflow as tf。
我正在运行我的终端而不是rosetta(这是另一个问题的解决方案):
(base) user@useros ~ % uname -m
arm64
Run Code Online (Sandbox Code Playgroud)
当我激活我的环境时,我仍然得到:
(venv) (base) user@useros ~ % uname -m
arm64
Run Code Online (Sandbox Code Playgroud)
如果我运行文件,$(which python)我会得到以下信息: 基础上:
(base) user@useros ~ % file $(which python)
/Users/user/opt/anaconda3/bin/python: Mach-O 64-bit executable x86_64
Run Code Online (Sandbox Code Playgroud)
在 venv 上:
(venv) (base) user@useros ~ % file $(which python)
/Users/user/venv/bin/python: Mach-O 64-bit executable x86_64
Run Code Online (Sandbox Code Playgroud)
为什么我在这里得到“Mach-O 64-bitexecutable x86_64”,即使我之前得到“arm64”?这让我很困惑,可能是我的代码无法工作的原因。
我使用 ggplot2 在一页中将三个不同的集合绘制为三个箱线图。在每组中,我想强调一个点,并说明该点与其他点相比的位置,它是否在方框内?或外面。
这是我的数据点
CDH 1KG NHLBI
CDH 301 688 1762
RS0 204 560 21742
RS1 158 1169 1406
RS2 182 1945 1467
RS3 256 2371 1631
RS4 198 580 1765
RS5 193 524 1429
RS6 139 2551 1469
RS7 188 702 1584
RS8 142 4311 1461
RS9 223 916 1591
RS10 250 794 1406
RS11 185 539 1270
RS12 228 641 1786
RS13 152 557 1677
RS14 225 1970 1619
RS15 196 458 1543
RS16 203 2891 1528
RS17 …Run Code Online (Sandbox Code Playgroud) 我有一个文件看起来像
旧数据
alireza,mahdi,alireza,mohammad
alireza,olivia,amireza,hasan
alireza,alireza,alireza,alireza
Run Code Online (Sandbox Code Playgroud)
新数据
0.54:30.36:N 0.54:32.31:N 0.54:30.36:Y
0.54:30.36:Y 0.54:32.31:N 0.54:30.36:Y
0.54:30.36:N 0.54:32.31:N 0.54:30.36:Y
0.54:30.36:N 0.54:32.31:N 0.54:30.36:N
Run Code Online (Sandbox Code Playgroud)
我想算一下每行说"Y"的数量,
所以输出就是
1
2
1
0
Run Code Online (Sandbox Code Playgroud)
所以我可以像"grep -w":Y'myfile'那样grep它,但后来我不知道怎么算!从那以后......
**更新我很抱歉更改数据和可能的模式.我想呈现一种简单易懂的格式,但我没有成功.我再次道歉.
我试图说明33个不同变量的直方图.由于变量的数量,我认为"旁边"不同的颜色我需要以清晰的方式标记每个条,即使使用箭头,如果它可行.
我想知道1)我如何在R 2中定义33种不同的颜色?我如何标记它们,比如在X轴下方垂直相距一定距离以使我的图形更清晰.
我正在使用Plotrix包中的multhist功能,对于数据,您可以只对33个不同长度的随机向量进行成像!
谢谢
python ×5
r ×3
ggplot2 ×2
amazon-s3 ×1
apple-m1 ×1
awk ×1
bash ×1
boto3 ×1
graphics ×1
grep ×1
histogram ×1
hyperlink ×1
macos ×1
pdf ×1
plotly-dash ×1
postscript ×1
powerpoint ×1
pymongo ×1
python-3.x ×1
regex ×1
tensorflow ×1