我在PyCharm中有以下代码
import pandas as pd
import numpy as np
import matplotlib as plt
df = pd.read_csv("c:/temp/datafile.txt", sep='\t')
df.head(10)
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)
我应该得到我的数据文件的前十行,但这些行不会出现PyCharm.
我检查了Project解释器,所有设置似乎都没问题.在正确的Python版本下安装了正确的软件包(numpy,pandas,matplotlib).
我究竟做错了什么?谢谢.
我在 Windows 10 上工作,在 anaconda 提示符下执行 pip install rasterio 时遇到错误。
(base) C:\Users\skywalker>pip install rasterio
Collecting rasterio
Using cached https://files.pythonhosted.org/packages/57/84/be5689470a73f5f8988cf44b81cb3493ebb8abbbebb69768c8fc86fccdd5/rasterio-1.0.24.tar.gz
Complete output from command python setup.py egg_info:
INFO:root:Building on Windows requires extra options to setup.py to locate needed GDAL files. More information is available in the README.
ERROR: A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
Command "python setup.py egg_info" failed with error code 1 in …Run Code Online (Sandbox Code Playgroud) 我是 MaskRCNN 的新手。我已将 15 个图像添加到dataset/train 文件夹中,但是在运行代码时出现该行错误
image = skimage.io.imread(image_path)
Run Code Online (Sandbox Code Playgroud)
错误是:
ValueError: Could not find a backend to open /Users/deepali/Documents/CV Projects/wastedata-Mask_RCNN-multiple-classes/main/dataset/train/10.jpeg with iomode ri
Run Code Online (Sandbox Code Playgroud)
整个代码如下:
import os
import sys
import json
import datetime
import numpy as np
import skimage.draw
import cv2
from skimage import io
from mrcnn.visualize import display_instances
import matplotlib.pyplot as plt
# Root directory of the project
ROOT_DIR = os.path.abspath("/Users/deepali/Documents/Mask_RCNN-multiple-classes/")
# Import Mask RCNN
sys.path.append(ROOT_DIR) # To find local version of the library
from mrcnn.config import Config …Run Code Online (Sandbox Code Playgroud) 使用 tensorflow 2.4.1
当我运行我的程序时,我收到此错误并且无法使用我的gpu.
我在用CUDA 11.0,cudnn 8.0
2021-02-07 03:36:18.132005: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
WARNING:tensorflow:From D:/PycharmProjects/pythonProject/models/kp?,i.py:5: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2021-02-07 03:36:19.735127: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler …Run Code Online (Sandbox Code Playgroud) 如何将 tkinter 文本小部件的一部分标记为只读?也就是说,我希望能够只允许在小部件的某些部分进行编辑。例如,我想只允许在提示之后而不是之前进行编辑,以模拟控制台。
我是qt designer和python的新手.我想创建一个我应该显示图像的简单项目.
我使用了"图形视图"小部件,并将其命名为"graphicsView".我写了这些功能:
def function(self):
image=cv2.imread('C:/Users/Hamid/Desktop/1.jpg',1)
self.show_frame_in_display(image)
def show_frame_in_display(self,frame):
image = QImage(frame, frame.shape[1], frame.shape[0],
frame.strides[0], QImage.Format_RGB888)
self.graphicsView.setPixmap(QPixmap.fromImage(image))
Run Code Online (Sandbox Code Playgroud)
但它给出了这个错误:
File "C:/Users/Hamid/Documents/untitled/hamid.py", line 54, in show_frame_in_display
self.graphicsView.setPixmap(QPixmap.fromImage(image))
AttributeError: 'QGraphicsView' object has no attribute 'setPixmap'
Run Code Online (Sandbox Code Playgroud)
我该怎么办?谢谢.
我正在尝试使用 python 中的 for 循环创建列表列表。我的计划是使用两个单独的循环;一个循环创建大列表以放入小列表,另一个循环创建小列表并将它们附加到大列表。
这被用来制作“战舰”类型的游戏,其中有 10x10 网格。
这是我遇到困难的代码块:
for i in range(0,10):
(newlist,(i))=[]
Run Code Online (Sandbox Code Playgroud)
该特定代码要完成的唯一任务是创建 10 个新列表,每个列表都有不同的名称。例如,循环的第一个循环将创建list0,第二个循环将创建list1,依此类推,直到list9。
从理论上讲,我认为这段代码没有任何问题。当您将字符串放入新变量而不是创建新列表时,它也可以工作。
每当我运行该程序时,我都会收到错误
ValueError: not enough values to unpack (expected 2, got 0)
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会发生这种情况,如果这里有人能帮助我,我将非常感激。
该问题与 matplotlib 条形图有关。具体来说,当我绘制条形图时,有些条形不可见。
点和条使用相同的数据系列,因此应该位于相同的位置
。
我不知道这个问题的根源是什么,这就是我发布这个问题的原因。我还注意到,对于同一个图,当我将窗口放大到全屏时,缺失的条会神奇地出现
与第一张图片相同的数据系列,只是全屏窗口
。
当我改变绘图的颜色时也会发生同样的情况,所以假设我使用:
artist = plot.bar(x_data_series, y_data_series, color="black")
Run Code Online (Sandbox Code Playgroud)
现在我有这个不完整的图表,但是当我使用时(只是在之后第二次设置颜色):
artist = plot.bar(x_data_series, y_data_series, color="black")
matplotlib.artist.setp(artist, color="black")
Run Code Online (Sandbox Code Playgroud)
我明白了:
现在所有栏都可见
。
当我放大这个不完整的图表时,也会发生同样的情况:
这里所有的栏也是可见的
。
更重要的是,“看不见的条”,当它们可见时,它们似乎比其他条粗一点,但是它们在艺术家属性中的宽度与您在此处看到的相同:
其中一根较粗,另一根为“正常”,宽度均为 0.8
。
为了给您提供更多信息,这是嵌入在 tkinter 中的图表。以下是图形、画布和轴(父框架只是放置绘图的框架):
figure = Figure(dpi=100)
plot = figure.add_subplot(111)
canvas = FigureCanvasTkAgg(figure, parent_frame)
Run Code Online (Sandbox Code Playgroud)
我找到的“解决方法”对我来说并不令人满意,我真的很想找到问题的根源,而且宽度问题是我无法弄清楚的。
我正在尝试为字幕抓取一个YouTube页面.不幸的是,它没有按要求加载所有内容.我很想知道我哪里出错了.
请求参数:
https://www.youtube.com/timedtext_editor?action_mde_edit_form=1&v=Nxb2s2Mv6Pw&lang=en&bl=vmp&forceedit=captions&tab=captions
Run Code Online (Sandbox Code Playgroud)
所以我发现这是唯一的Url-ID ...... Nxb2s2Mv6Pw我可以相应地替换它.
如果我运行下面的代码,它不会捕获<textarea yt-uix-form-input-textarea ...>我需要它找到的标记.
我拼命想避免使用Selenium捕获它,因为我有很多链接需要迭代并重复这个过程.正如你可以通过下面的代码告诉我的,我试图加入一个延迟的时间等待页面加载,但没有.
import os
import codecs
import sys
import requests
from bs4 import BeautifulSoup
channel = 'https://www.youtube.com/timedtext_editor?action_mde_edit_form=1&v=dto4koj5DTA&lang=en'
s = requests.Session()
time.sleep(5)
# s.headers['User-Agent'] = USER_AGENT
r = s.get(channel)
time.sleep(5)
html = r.text
soup = BeautifulSoup(html, 'lxml')
for i in soup.find_all('div'):
print(i)
Run Code Online (Sandbox Code Playgroud)
请指教.
如何将 B 列转换为 python 中的转换矩阵?
矩阵的大小为 19,这是 B 列中的唯一值。数据集中共有 432 行。
time A B
2017-10-26 09:00:00 36 816
2017-10-26 10:45:00 43 816
2017-10-26 12:30:00 50 998
2017-10-26 12:45:00 51 750
2017-10-26 13:00:00 52 998
2017-10-26 13:15:00 53 998
2017-10-26 13:30:00 54 998
2017-10-26 14:00:00 56 998
2017-10-26 14:15:00 57 834
2017-10-26 14:30:00 58 1285
2017-10-26 14:45:00 59 1288
2017-10-26 23:45:00 95 1285
2017-10-27 03:00:00 12 1285
2017-10-27 03:30:00 14 1285
...
2017-11-02 14:00:00 56 998
2017-11-02 14:15:00 57 998
2017-11-02 …Run Code Online (Sandbox Code Playgroud) python ×10
pandas ×2
tkinter ×2
dataframe ×1
matplotlib ×1
pip ×1
pycharm ×1
python-2.7 ×1
python-3.x ×1
qt-designer ×1
rasterio ×1
scikit-image ×1
tensorflow ×1
text-widget ×1
web-scraping ×1