-2
我正在运行我的整个活动目录对用户帐户试图找到不属于。 使用我的代码我的输出给了我只在用户名列中出现一次的单词。尽管我正在分析一列数据,但我想保留数据的所有列。Python:使用熊猫,我如何选择输出中的列?
from pandas import DataFrame, read_csv
import pandas as pd
f1 = pd.read_csv('lastlogonuser.txt', sep='\t', encoding='latin1')
f2 = pd.read_csv('UserAccounts.csv', sep=',', encoding ='latin1')
f2 = f2.rename(columns={'Shortname':'User Name'})
f = pd.concat([f1, f2])
counts = f['User Name'].value_counts()
f = counts[counts == 1]
f
我得到这样的事情,当我运行我的代码:
sample534 1
sample987 1
sample342 1
sample321 1
sample123 1
我想一切从txt文件中的数据在我出去放出来,但我还是只是想分析用户名列。如何将所有数据保留在所有列中,还是必须使用不同的字数才能包含所有数据列?
我想是这样的:数据
User Name Description
1 sample534 Journal Mailbox managed by
1 sample987 Journal Mailbox managed by
1 sample342 Journal Mailbox managed by
1 sample321 Journal Mailbox managed by
1 sample123 Journal Mailbox managed by
样品我使用:根据您的描述
Account User Name User CN Description
ENABLED MBJ29 CN=MBJ29,CN=Users Journal Mailbox managed by
ENABLED MBJ14 CN=MBJ14,CN=Users Journal Mailbox managed by
ENABLED MBJ08 CN=MBJ30,CN=Users Journal Mailbox managed by
ENABLED MBJ07 CN=MBJ07,CN=Users Journal Mailbox managed by
请显示你的数据文件的样本。 – BrenBarn
请不要*描述*您的数据。在你的文章中包含* actual *数据的*样本*。 – BrenBarn
[如何制作好重现熊猫的例子](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – MaxU