Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 清除数据帧中单元格值的最佳方法_Python_Dataframe - Fatal编程技术网

Python 清除数据帧中单元格值的最佳方法

Python 清除数据帧中单元格值的最佳方法,python,dataframe,Python,Dataframe,我正在拿一个RSS(“”)并将其上传到SQL数据库。以下是我的步骤: 从这个URL我能够创建一个熊猫数据框架,我将上传到一个SQL数据库。数据框中的列名是标题、链接、摘要、作者和标记。清理摘要栏并清除所有标记的最佳方法是什么 '<!-- SC_OFF --><div class="md"><p>The title says most of it, I’m running about a 12-13 min mile. I haven’t run in abou

我正在拿一个RSS(“”)并将其上传到SQL数据库。以下是我的步骤:

从这个URL我能够创建一个熊猫数据框架,我将上传到一个SQL数据库。数据框中的列名是标题、链接、摘要、作者和标记。清理摘要栏并清除所有标记的最佳方法是什么

'<!-- SC_OFF --><div class="md"><p>The title says most of it, I’m running about a 12-13 min mile. I haven’t run in about 4.5 years and I need to get to my fastest 1.5 with more in the tank afterward, and I need it to be solid. </p> <p>I’ve read blogs and running guides, but I thought I’d get it from the source, people who just love to run, just like the way I used to love to lift. </p> <p>I guess my question is, where do I start? Some say football conditioning, others say just run… Some even say just walk. I’m trying to slim down fast and have a solid mile and a half to 2-mile sprint. </p> <p>The only other conditioning I’m doing right now is three days of fight sports (2 Krav/kickboxing, 1 combat fitness style). Looking at running 3ish days and taking Sunday off.</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/Logical_penguin"> /u/Logical_penguin </a> &#32; to &#32; <a href="https://www.reddit.com/r/running/"> r/running </a> <br/> <span><a href="https://www.reddit.com/r/running/comments/drt0nf/im_65_335lbs_ex_amature_strong_man_and_i_need_help/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/running/comments/drt0nf/im_65_335lbs_ex_amature_strong_man_and_i_need_help/">[comments]</a></span>' 

”标题上说,我跑了大约12-13分钟英里。我已经有4.5年没有跑步了,我需要在赛后的1.5英里内跑得最快,而且我需要它是坚固的

我读过博客和跑步指南,但我想我会从源头上得到,那些喜欢跑步的人,就像我过去喜欢举重的方式一样

我想我的问题是,从哪里开始?有人说是足球训练,也有人说只是跑步……甚至有人说只是走路。我正在努力快速减肥,并有一个坚实的一英里半到2英里的冲刺

我现在唯一正在做的其他训练是三天的格斗运动(2节Krav/跆拳道,1节格斗健身风格)。期待着三天的跑步和周日的休息。

&32;提交人 至
;'
我可以用下面的一部分

df['summary'] = df['summary'].map(lambda x: x.lstrip('<!-- SC_OFF --->'))
df['summary']=df['summary'].map(lambda x:x.lstrip(“”))
但是,对于摘要列中的所有内容,这将花费太长的时间。

import re
import re
df['summary'] = df['summary'].map(lambda x: re.sub('<[^<]+?>', '', x))

df['summary']=df['summary'].map(λx:re.sub('code>re.sub
.lstrip
工作得快吗?你也能提供一些时间计算吗?@Tserenjamts它们非常不同。lstrip和rstrip不会达到你的目标,因为它们之间有标记。正则表达式在匹配标记格式中的任何内容方面都非常强大。是的,我知道我在问你如何ast是
re.sub
:))