小编Mth*_*Clv的帖子

在 jupyter 实验室中未呈现 Plotly Express

以下代码不会在 Jupyter 实验室中呈现:

%matplotlib widget
import plotly.express as px  
import numpy as np 
import pandas as pd

df = pd.DataFrame(np.random.randint(0,100,size=(5, 4)), columns=list('ABCD'))
px.bar(df, x='A', y='B')
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明 我试图安装这里提到的所有依赖项和扩展 https://plot.ly/python/getting-started/#jupyterlab-support-python-35

还有这里的步骤 https://github.com/matplotlib/jupyter-matplotlib

没有任何效果

这是我的设置:

jupyter lab --version
1.0.2

python --version
Python 3.6.1 :: Continuum Analytics, Inc.

conda list jupyterlab
# packages in environment at C:\Users\***\Anaconda3:
#
# Name                    Version                   Build  Channel
jupyterlab                1.0.2            py36hf63ae98_0
jupyterlab_launcher       0.13.1                   py36_0
jupyterlab_server         1.0.0                      py_0

conda list nodejs
# packages in environment at C:\Users\***\Anaconda3:
#
# Name                    Version …
Run Code Online (Sandbox Code Playgroud)

python plotly jupyter-lab plotly-express

10
推荐指数
1
解决办法
8719
查看次数

仅在具有两个类并且共享相同的第一个类时才选择元素

我在要解析的HTML中有这些元素:

<td class="line"> GARBAGE </td>
<td class="line text"> I WANT THAT </td>
<td class="line heading"> I WANT THAT </td>
<td class="line"> GARBAGE </td>
Run Code Online (Sandbox Code Playgroud)

如何创建一个CSS选择器,选择具有属性类行和类别的元素(可能是标题,文本或其他任何东西)但不仅仅属性类行?

我试过了:

 td[class=line.*]
 td.line.*
 td[class^=line.]
Run Code Online (Sandbox Code Playgroud)

编辑

我正在使用Python和BeautifulSoup:

url = 'http://www.somewebsite'
res = requests.get(url)
res.raise_for_status()
DicoSoup = bs4.BeautifulSoup(res.text, "lxml")
elems = DicoSoup.select('body div#someid tr td.line')
Run Code Online (Sandbox Code Playgroud)

我正在考虑修改最后一块,即td.line到类似的东西td.line.whateverotherclass(但不是单独的td.line,否则我的选择器就足够了)

html python beautifulsoup css-selectors html-parsing

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