![](/img/trans.png)
[英]How do I append the data in text files and combine multiple text files into one text file using python?
[英]iPython:Using Pandas, How do I combine multiple text files to find recurring usernames?
我正在使用 Pandas 來計算來自 2 個不同大文本文件的重復用戶名。 如何讓我的代碼同時分析兩個文件中的數據? 現在我只能運行一個文本文件,所以沒有發生多次。
這是我的代碼:
import pandas as pd
fixed_df = pd.read_csv('sample.txt', sep=';', encoding='latin1')
fixed_df['User Name'].value_counts().nsmallest()
合並這樣的文件
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.