小编Rah*_*ava的帖子

如何使用模块re从数据框列中删除特殊characers?

嘿,我已经看到了这个链接,但在那里他们已经使用了re模块,这就是我在这里发布的原因.希望您理解并删除副本.

这是链接.我想用re模块.

表:

A    B    C    D
1    Q!   W@   2
2    1$   E%   3
3    S2#  D!   4
Run Code Online (Sandbox Code Playgroud)

在这里,我想从column B和删除特殊字符C.我已经使用.transform()但我想re尽可能使用它,但我收到了错误.

输出:

A    B    C    D   E   F
1    Q!   W@   2   Q   W
2    1$   E%   3   1   E
3    S2#  D!   4   S2  D
Run Code Online (Sandbox Code Playgroud)

我的代码:

df['E'] = df['B'].str.translate(None, ",!.; -@!%^&*)(")
Run Code Online (Sandbox Code Playgroud)

它只有在我知道什么是特殊字符时才有用.

但我想使用re哪种方式最好.

import re
#re.sub(r'\W+', '', your_string)
df['E'] = re.sub(r'\W+', '', df['B'].str) …
Run Code Online (Sandbox Code Playgroud)

python string pandas

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

通过纱线安装软件包时收到未满足的对等依赖项的警告,即使它们已添加到节点模块中

系统:

\n\n
    \n
  • 操作系统:macOS Mojave 10.14.5
  • \n
  • CPU:(4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  • \n
  • 内存:50.37 MB / 8.00 GB
  • \n
  • 外壳:5.3 - /bin/zsh

    \n\n

    二进制文件:

  • \n
  • 节点:12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node

  • \n
  • 纱线:1.19.1 - /usr/local/bin/yarn
  • \n
  • npm:6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm

    \n\n

    npm 包:

  • \n
  • babel-plugin-styled-components:^1.10.6 => 1.10.6

  • \n
  • 样式组件:^5.0.0-rc.1 => 5.0.0-rc.1
  • \n
\n\n

为什么我收到此警告,即使我可以在 node_modules 中看到包

\n\n
yarn add eslint-config-airbnb                                                     \nyarn add v1.19.1\n[1/4]   Resolving packages...\n[2/4]   Fetching packages...\n[3/4]   Linking dependencies...\nwarning "eslint-config-airbnb > eslint-config-airbnb-base@14.0.0" has unmet peer dependency "eslint-plugin-import@^2.18.2".\nwarning " > eslint-config-airbnb@18.0.1" has …
Run Code Online (Sandbox Code Playgroud)

yarnpkg

5
推荐指数
0
解决办法
1005
查看次数

如何在Windows 7上安装psycopg2

我已经尝试过pip install psycopg2以下错误:

错误:

(ScrapeProj) C:\Users\e2sn7cy\Documents\GitHub\scraper>pip install psycopg2==2.5.4
Collecting psycopg2==2.5.4
  Using cached psycopg2-2.5.4.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info\psycopg2.egg-info
    writing pip-egg-info\psycopg2.egg-info\PKG-INFO
    writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
    writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt
    writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with …
Run Code Online (Sandbox Code Playgroud)

postgresql psycopg2 python-2.7

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

BeautifulSoup如何在标签后提取文本

我不知道如何使用BeautifulSoup达到以下段落以及如何提取我想要的特定文本.因为我是Python和BS4的新手.

我的HTML如下:

<div class="inner-content">
  <div class="bred"></div>
  <div class="clrbth"></div>
  <h1></h1>
  <h4></h4>
  ...
  ...
  ...
  <p></p>
  <p></p>
  <p>

<!--This text I don't want -->

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
    <br></br>


<!-- The text I want to extract using BeautifulSoup-->

    It is a long established …
Run Code Online (Sandbox Code Playgroud)

html python beautifulsoup

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

如何从本地安装Vagrant VM

我正在学习Udacity课程,他们让我安装Vagrant.但由于.box文件的大小,我首先从其他网络下载到本地,我得到了这个tar文件trusty-server-cloudimg-i386-vagrant-disk1.tar.他们让我下载他们的文件夹fullstack.该文件夹包含以下结构:

|--fullstack
    |--vagrant
        |--.vagrant
        |--catalog
        |--forum
            |--forum.py
            |--forum.sql
            |--forumdb.py
        |--tournament
            |--tournament.py
            |--tournament.sql
            |--tournament_test.py
        |--pg_config
        |--Vagrantfile
Run Code Online (Sandbox Code Playgroud)

流浪者你可以从这个链接看到他们是如何做的.现在,当我正在使用vagrant upgit bash,前往fullstack/vagrant代码的位置正在起作用:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty32' could not be found. Attempting to find and in
stall...
    default: Box Provider: virtualbox
    defa

ult: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty32'
    default: URL: https://atlas.hashicorp.com/ubuntu/trusty32
==> default: Adding box 'ubuntu/trusty32' (v20150818.0.0) …
Run Code Online (Sandbox Code Playgroud)

virtualbox vagrant vagrantfile vagrant-windows

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