简体   繁体   English

iPython:使用 Pandas,如何组合多个文本文件以查找重复出现的用户名?

[英]iPython:Using Pandas, How do I combine multiple text files to find recurring usernames?

I'm using pandas to count recurring usernames from 2 different large text files.我正在使用 Pandas 来计算来自 2 个不同大文本文件的重复用户名。 How do I get my code to analyze the data from both files at the same time?如何让我的代码同时分析两个文件中的数据? Right now I have only been able to run one text file so nothing is occurring more than once.现在我只能运行一个文本文件,所以没有发生多次。

Here is my Code:这是我的代码:

import pandas as pd
fixed_df = pd.read_csv('sample.txt', sep=';', encoding='latin1')
fixed_df['User Name'].value_counts().nsmallest()

Combine files like this合并这样的文件

fixed_df1 = pd.read_csv('sample1.txt', sep=';', encoding='latin1')
fixed_df2 = pd.read_csv('sample2.txt', sep=';', encoding='latin1')
fixed_df = pd.concat([fixed_df1, fixed_df2])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在文本文件中追加数据并使用 python 将多个文本文件合并为一个文本文件? - How do I append the data in text files and combine multiple text files into one text file using python? 如何使用 if & else 组合 pandas 中的三个文本列 - How do I combine three text column in pandas using if & else 如何将多个 CSV 文件与 Python 和 Pandas 合并为一个? - How can I combine multiple CSV files into one with Python and Pandas? 如何使用 Python 将多个 CSV 文件合并为一个具有不同工作表的 Excel 文件 - How do I combine multiple CSV files into one excel files with different sheets using Python 如何使用Pandas将共享数据的多行CSV组合成一行? - How do I combine multiple rows of a CSV that share data into one row using Pandas? 使用Python和Pandas合并多个CSV文件 - Combine multiple CSV files using Python and Pandas 如何找到 IPython 单元格的宽度? - How do I find the width of an IPython cell? 如何在IPython中结合%pylab和%run魔术命令? - How do I combine the %pylab and %run magic commands in IPython? 如何在 IPython 中自定义文本颜色? - How do I customize text color in IPython? 如何使用 pandas 从遵循重复模式的 dataframe 列中提取数字? - How do I extract numbers from a dataframe column which follows a recurring pattern using pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM