小编Muh*_*san的帖子

AttributeError:type object'numpy.ndarray'没有属性'__array_function__'

我将numpy升级到最新版本,现在我在导入numpy时遇到以下错误:

AttributeError:类型对象'numpy.ndarray'没有属性' array_function '

我正在使用numpy版本1.16.

python numpy python-3.x

8
推荐指数
2
解决办法
6028
查看次数

Python 多处理在连接处挂起

我正在读取一个视频文件,每 20 帧我将第一帧存储在输入队列中。一旦我在输入队列中获得了所有必需的帧,我就会运行多个进程来对这些帧执行一些操作并将结果存储在输出队列中。但代码总是卡在 join 处,我尝试了针对此类问题提出的不同解决方案,但似乎都不起作用。

import numpy as np
import cv2
import timeit
import face_recognition
from multiprocessing import Process, Queue, Pool
import multiprocessing
import os

s = timeit.default_timer()

def alternative_process_target_func(input_queue, output_queue):

    while not output_queue.full():
        frame_no, small_frame, face_loc = input_queue.get()
        print('Frame_no: ', frame_no, 'Process ID: ', os.getpid(), '----', multiprocessing.current_process())
        #canny_frame(frame_no, small_frame, face_loc)

        #I am just storing frame no for now but will perform something else later
        output_queue.put((frame_no, frame_no)) 

        if output_queue.full():
            print('Its Full ---------------------------------------------------------------------------------------')
        else:
            print('Not Full')

    print(timeit.default_timer() - s, ' seconds.') …
Run Code Online (Sandbox Code Playgroud)

python parallel-processing process multiprocessing

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

来自pandas数据帧的信息矩阵

我有一个像下面这样的pandas数据帧:

    Customer Id  year
0       1510220024  2017
1       1510270013  2017
2       1511160047  2017
3       1512100014  2017
4       1603180006  2017
5       1605030030  2017
6       1605160013  2017
7       1606060008  2017
8       1510220024  2018
9       1606270014  2017
10      1608080011  2017
11      1608090002  2017
12      1511160047  2018
13      1606270014  2018
Run Code Online (Sandbox Code Playgroud)

我想从上面的数据框构建以下矩阵:

     2017 2018
2017  11   3
2018   3   3
Run Code Online (Sandbox Code Playgroud)

该矩阵表明2017年共有11个客户,其中3个也出现在2018年,依此类推.实际上,我有7年的数据,所以它将是7x7矩阵.我现在正在努力一段时间,但无法做到这一点.

python dataframe pandas

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

Plotly:如何在使用 plotly express line 时在 hoverinfo 中格式化日期?

我正在使用以下代码使用 plotly express line 显示时间序列数据。

fig = px.line(df, x="date", y="close", color="type" ,category_orders = co ,color_discrete_sequence = colors,
              line_group="type", title = company)

fig.update_layout(height=500, width=1500)#hovermode="x unified"
fig.show()
Run Code Online (Sandbox Code Playgroud)

但是在悬停时的绘图中,它以以下格式显示日期:“月,年”,即它不显示日期。但我希望以以下格式显示日期:“月日,年”。

python data-visualization plotly plotly-express

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