小编Nih*_*hal的帖子

如何为我的SVG路径设置动画

我有一个SVG我试图用animejs动画.

基本上它是一个选择路径图.

我设法制作动画,但结果是错误的.

我要这个:

在此输入图像描述

var lineDrawing = anime({
  targets: 'path',
  strokeDashoffset: [anime.setDashoffset, 0],
  easing: 'easeInOutCubic',
  duration: 4000,
  begin: function(anim) {
    document.querySelector('path').setAttribute("stroke", "#4a56f2");
    document.querySelector('path').setAttribute("fill", "none");
  },
  complete: function(anim) {
  },
  autoplay: false
});

document.querySelector('.play-drawing').onclick = lineDrawing.restart;
Run Code Online (Sandbox Code Playgroud)
body {
  margin: 20px;
  font-family: 'Lato';
  font-weight: 300;
  font-size: 1.2em;
}

#anime-demo {
  position: relative;
}

svg {
   padding: 10px;
}

button {
  background: orange;
  color: white;
  margin: 5px;
  padding: 10px;
  border-radius: 4px;
  font-family: 'Lato';
  cursor: pointer;
  border: none;
  outline: none;
}

button:hover {
  background: …
Run Code Online (Sandbox Code Playgroud)

html javascript svg svg-animate anime.js

13
推荐指数
2
解决办法
327
查看次数

如何将pandas数据框显示到现有的flask html表中?

这可能听起来像一个noob问题,但我坚持使用它,因为Python不是我最好的语言之一.

我有一个html页面,里面有一个表格,我想在其中显示一个pandas数据帧.最好的方法是什么?使用pandasdataframe.to_html?

PY

from flask import Flask;
import pandas as pd;
from pandas import DataFrame, read_csv;

file = r'C:\Users\myuser\Desktop\Test.csv'
df = pd.read_csv(file)
df.to_html(header="true", table_id="table")
Run Code Online (Sandbox Code Playgroud)

HTML

<div class="table_entrances" style="overflow-x: auto;">

  <table id="table">

    <thead></thead> 
    <tr></tr>

  </table>

</div>
Run Code Online (Sandbox Code Playgroud)

python flask pandas pandas-datareader

13
推荐指数
4
解决办法
2万
查看次数

PyCharm:进程以退出代码0结束

我是PyCharm的新手,我已经'处理完了退出代码0'而不是得到(683,11)因此(请参阅附件),你能帮助我吗?非常欣赏它!

最好的问候,ET

在此输入图像描述

python pycharm

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

json.decoder.JSONDecodeError:额外数据:第2行第1列(字符190)

我正在运行以下代码-

import json

addrsfile = 
open("C:\\Users\file.json", 
"r")
addrJson = json.loads(addrsfile.read())
addrsfile.close()
if addrJson:
    print("yes")
Run Code Online (Sandbox Code Playgroud)

但是给我以下错误-

import json

addrsfile = 
open("C:\\Users\file.json", 
"r")
addrJson = json.loads(addrsfile.read())
addrsfile.close()
if addrJson:
    print("yes")
Run Code Online (Sandbox Code Playgroud)

有人帮我吗?

JSON文件就像-

{"name": "XYZ", "address": "54.7168,94.0215", "country_of_residence": "PQR", "countries": "LMN;PQRST", "date": "28-AUG-2008", "type": null}
{"name": "OLMS", "address": null, "country_of_residence": null, "countries": "Not identified;No", "date": "23-FEB-2017", "type": null}
Run Code Online (Sandbox Code Playgroud)

python json python-3.x

8
推荐指数
1
解决办法
4万
查看次数

Cumsum是现有Pandas数据中的新列

我有一个pandas数据框定义为:

A   B   SUM_C      
1   1   10     
1   2   20   
Run Code Online (Sandbox Code Playgroud)

我想做一个SUM_C的累积和,并将其作为新列添加到同一个数据帧.换句话说,我的最终目标是拥有如下所示的数据框:

A   B   SUM_C   CUMSUM_C       
1   1   10      10     
1   2   20      30   
Run Code Online (Sandbox Code Playgroud)

在group()使用pandas中的cumsum显示了生成新数据帧的可能性,其中列名SUM_C被累积和替换.但是,我的问题是将累积和作为新列添加到现有数据框中.

谢谢

python dataframe pandas cumsum

7
推荐指数
1
解决办法
8384
查看次数

python 中的日语 txt 文件和 wordcloud 输出出现问题

我参考了阿穆勒的词云和其他一些词云。事情是这样的:

\n\n
#!c:/Python27/python.exe\n# coding: UTF-8\nfrom os import path\nfrom wordcloud import WordCloud\nimport MeCab as mc\n\nd = path.dirname("C:\\Users\\BobLeponge\\Desktop\\jpn\\JPNTEXT.txt")\ntext = open(path.join(d, \'JPNTEXT.txt\')).read()\ntext = text.decode("utf-8")\n\ndef mecab_analysis(text):\n    t = mc.Tagger(\'-Ochasen -d/usr/local/Cellar/mecab/0.996/lib/mecab/dic/mecab-ipadic-neologd/\')\n    enc_text = text.encode(\'utf-8\')\n    node = t.parseToNode(enc_text)\n    output = []\n    while(node):\n        if node.surface != "":\n            word_type = node.feature.split(",")[0]\n            if word_type in ["\xe5\xbd\xa2\xe5\xae\xb9\xe8\xa9\x9e", "\xe5\x8b\x95\xe8\xa9\x9e","\xe5\x90\x8d\xe8\xa9\x9e", "\xe5\x89\xaf\xe8\xa9\x9e"]:\n                output.append(node.surface)\n        node = node.next\n        if node is None:\n            break\n    return output\n\ndef create_wordcloud(text):\n    fpath = "C:\\WINDOWS\\Fonts\\NotoSansMonoCJKjp-Regular.otf"\n    stop_words = [ u\'\xe3\x81\xa6\xe3\x82\x8b\', u\'\xe3\x81\x84\xe3\x82\x8b\', u\'\xe3\x81\xaa\xe3\x82\x8b\', u\'\xe3\x82\x8c\xe3\x82\x8b\', u\'\xe3\x81\x99\xe3\x82\x8b\', u\'\xe3\x81\x82\xe3\x82\x8b\', u\'\xe3\x81\x93\xe3\x81\xa8\', u\'\xe3\x81\x93\xe3\x82\x8c\', u\'\xe3\x81\x95\xe3\x82\x93\', u\'\xe3\x81\x97\xe3\x81\xa6\', \\\n         u\'\xe3\x81\x8f\xe3\x82\x8c\xe3\x82\x8b\', u\'\xe3\x82\x84\xe3\x82\x8b\', …
Run Code Online (Sandbox Code Playgroud)

python utf-8 word-cloud atom-editor

6
推荐指数
0
解决办法
503
查看次数

keras CNN:训练集和验证集相同,但准确度不同

我知道这是一件非常糟糕的事情,但我注意到使用 keras mobilenet 有一些奇怪的事情:

我使用相同的数据进行训练和验证集:

train_generator = train_datagen.flow_from_directory(
    train_dir,
    target_size=(IM_WIDTH, IM_HEIGHT),
    batch_size=batch_size,
    class_mode = "categorical"
)
validation_generator = train_datagen.flow_from_directory(
  train_dir,
  target_size=(IM_WIDTH, IM_HEIGHT),
  class_mode = "categorical"
)
Run Code Online (Sandbox Code Playgroud)

但我没有得到相同的准确度!

epoch 30/30 - loss: 0.3485 - acc: 0.8938 - val_loss: 1.7545 - val_acc: 0.4406

与验证集相比,我似乎过度拟合了训练集......但它们应该是相同的!这怎么可能?

deep-learning keras tensorflow

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

如何使用无限循环的目标函数创建一个可停止的线程

假设我想run_forever()在一个线程中运行一个名为的函数,但仍然可以通过按Ctrl+ 来"停止" C.我已经看到了使用StoppableThread子类的方法threading.Thread,但这些似乎涉及将目标函数"复制"到该子类中.我想保持功能"它在哪里".

请考虑以下示例:

import time
import threading

def run_forever():  # An externally defined function which runs indefinitely
    while True:
        print("Hello, world!")
        time.sleep(1)

class StoppableThread(threading.Thread):
    """Thread class with a stop() method. The thread itself has to check
    regularly for the stopped() condition."""

    def __init__(self, *args, **kwargs):
        super(StoppableThread, self).__init__(*args, **kwargs)
        self._stop = threading.Event()

    def stop(self):
        self._stop.set()

    def stopped(self):
        return self._stop.isSet()

    def run(self):
        while not self.stopped():
            run_forever()             # This doesn't work
            # print("Hello, …
Run Code Online (Sandbox Code Playgroud)

python python-multithreading

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

Tensorflow 模型保存和加载

如何像我们在 keras 中所做的那样使用模型图保存张量流模型。我们可以保存整个模型(权重和图)并稍后导入,而不是在预测文件中再次定义整个图

在凯拉斯:

checkpoint = ModelCheckpoint('RightLane-{epoch:03d}.h5',monitor='val_loss', verbose=0,  save_best_only=False, mode='auto')
Run Code Online (Sandbox Code Playgroud)

将给出一个我们可以用于预测的 h5 文件

model = load_model("RightLane-030.h5")
Run Code Online (Sandbox Code Playgroud)

如何在本机张量流中做同样的事情

python deep-learning conv-neural-network keras tensorflow

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

将字符串格式的科学记数法转换为火花数据帧中的数字

Day_Date,timeofday_desc,Timeofday_hour,Timeofday_minute,Timeofday_second,value
2017-12-18,12:21:02 AM,0,21,2,“1.779209040E+08”
2017-12-19,12:21:02 AM,0,21,2,“1.779209040E+08”
2017-12-20,12:30:52 AM,0,30,52,“1.779209040E+08”
2017-12-21,12:30:52 AM,0,30,52,“1.779209040E+08”
2017-12-22,12:47:10 AM,0,47,10,“1.779209040E+08”
2017-12-23,12:47:10 AM,0,47,10,“1.779209040E+08”
2017-12-24,02:46:59 AM,2,46,59,“1.779209040E+08”
2017-12-25,02:46:59 AM,2,46,59,“1.779209040E+08”
2017-12-26,03:10:27 AM,3,10,27,“1.779209040E+08”
2017-12-27,03:10:27 AM,3,10,27,“1.779209040E+08”
2017-12-28,03:52:08 AM,3,52,8,“1.779209040E+08”
Run Code Online (Sandbox Code Playgroud)

我正在尝试将value列转换为177920904

val df1 = df.withColumn("s", 'value.cast("Decimal(10,4)")).drop("value").withColumnRenamed("s", "value")
Run Code Online (Sandbox Code Playgroud)

还尝试将值转换为Float, Double。始终将 null 作为输出

df1.select("value").show()


+-----------+
|   value   |
+-----------+
|       null|
|       null|
|       null|
|       null|
|       null|
|       null|
|       null|
|       null|
Run Code Online (Sandbox Code Playgroud)
df.printSchema

root
 |-- Day_Date: string (nullable = true)
 |-- timeofday_desc: string (nullable = true)
 |-- Timeofday_hour: string (nullable …
Run Code Online (Sandbox Code Playgroud)

scala dataframe apache-spark apache-spark-sql spark-shell

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