[英]I want to count the elements of a python list that is within a dataframe, and for the output to be a column in the dataframe. How do I do that?
[英]How do I clean this dataframe. I want to remove "\n" from the table using python without affecting the table
我使用网络抓取从 web 页面解析了这个 dataframe。 使用的库是 bs4(BeautifulSoup)、pandas、requests 和 urllib。 表格需要在csv下载,之后在tableau中进行数据可视化。 因此,在不影响任何行和列的情况下,我想从 dataframe 中删除“\n”。我们将不胜感激,请在此处输入图片描述。
你可以这样做:
rank_details["Pos"] = Pos.text.strip('\n')
我认为您的问题已在这个问题中得到解答。
更确切地说,
dataFrame.replace('\n', '', regex=True)
应该为你做。 请注意,在此之后,您可能还需要使用astype 方法从字符串的前导和尾随空格中去除字符串,并且还需要转换一些列(貌似Pos
应该是一个整数)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.