嘿,我已经看到了这个链接,但在那里他们已经使用了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) 外壳:5.3 - /bin/zsh
\n\n节点:12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
npm:6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
\n\nbabel-plugin-styled-components:^1.10.6 => 1.10.6
为什么我收到此警告,即使我可以在 node_modules 中看到包
\n\nyarn 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) 我已经尝试过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) 我不知道如何使用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) 我正在学习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 up时git 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) python ×2
html ×1
pandas ×1
postgresql ×1
psycopg2 ×1
python-2.7 ×1
string ×1
vagrant ×1
vagrantfile ×1
virtualbox ×1
yarnpkg ×1