简体   繁体   中英

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. 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])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM