我有两个CSV文件,两个文件都有多个列和行,我期待在两个文件的所有行之间获得差异.让我们假设Asset Tag Number文件之间是否存在差异,然后突出显示任何形式的差异(可能是粗略的值或适当的东西),而且,我们在这里有一个密钥,Serial Number它在两个文件上都是唯一的.因此,最好将行的差异转换为new.csv文件,并在删除相同行时突出显示差异.
仅仅为了refe,我有两个文件有超过100列..
我的实际数据列如下所示在csv文件中.
Columns: [Asset Tag Number_a, Serial Number_a, System Name_a, Domain_a, System manufacturer_a, Model Name_a, System Type_a, Critical Level_a, Purpose Level 1_a, Purpose2_a, ShareIndv_a, Site_a, Building_a, Room_a, Rack_a, serverCostCenter_a, User ID BU Grp Mgr_a, OS Name_a, OS Version_a, OS Type_a, Service Pack_a, Notification Group_a, Off The Network_a, First Name_a, Last Name_a, Manager Name_a, Status_a, BU Cost Center_a, BU CC Description_a, Organization Name_a, Higher Level BU_a, Business Contact_a, Description_a, Asset Type_a, System Type …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 pythons 正则表达式提取数字值(100.00 和 200.00),但是当我调用代码时它没有产生任何结果......我使用的是 python 版本 2.7
1)我的文件名是“file100”,我需要从中选择值..
# cat file100
Hi this doller 100.00
Hi this is doller 200.00
Run Code Online (Sandbox Code Playgroud)
2)这是我的python代码..
# cat count100.py
#!/usr/bin/python
import re
file = open('file100', 'r')
for digit in file.readlines():
myre=re.match('\s\d*\.\d{2}', digit)
if myre:
print myre.group(1)
Run Code Online (Sandbox Code Playgroud)
3)当我运行这段代码时,它没有产生任何东西,没有错误..没有..
# python count100.py
Run Code Online (Sandbox Code Playgroud) 在处理 SO 问题时,我使用 with 遇到了警告错误loc,具体细节如下:
数据帧示例:
第一个数据帧 df1 :
>>> data1 = {'Sample': ['Sample_A','Sample_D', 'Sample_E'],
... 'Location': ['Bangladesh', 'Myanmar', 'Thailand'],
... 'Year':[2012, 2014, 2015]}
>>> df1 = pd.DataFrame(data1)
>>> df1.set_index('Sample')
Location Year
Sample
Sample_A Bangladesh 2012
Sample_D Myanmar 2014
Sample_E Thailand 2015
Run Code Online (Sandbox Code Playgroud)
第二个数据帧 df2:
>>> data2 = {'Num': ['Value_1','Value_2','Value_3','Value_4','Value_5'],
... 'Sample_A': [0,1,0,0,1],
... 'Sample_B':[0,0,1,0,0],
... 'Sample_C':[1,0,0,0,1],
... 'Sample_D':[0,0,1,1,0]}
>>> df2 = pd.DataFrame(data2)
>>> df2.set_index('Num')
Sample_A Sample_B Sample_C Sample_D
Num
Value_1 0 0 1 0
Value_2 1 0 0 …Run Code Online (Sandbox Code Playgroud) 我有下面的代码可以工作,但是UserWarning在打印数据时它会抛出一些错误。
import pandas as pd
pd.set_option('display.height', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('expand_frame_repr', True)
data = pd.read_csv('/home/karn/plura/Test/Python_Pnada/Cyber_July.csv', usecols=['Platform ID', 'Safe', 'Target system address', 'Failure reason'])
hostData = data[data['Platform ID'].str.startswith("CS-Unix-")][data['Safe'].str.startswith("CS-NOI-DEFAULT-UNIX-ROOT")] [['Platform ID', 'Safe', 'Target system address','Failure reason']]
hostData.reset_index(level=0, drop=True)
print(hostData)
Run Code Online (Sandbox Code Playgroud)
以下是用户警告..
./CyberCSV.py:12: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
hostData = data[data['Platform ID'].str.startswith("CS-Unix-")][data['Safe'].str.startswith("CS-NOI-DEFAULT-UNIX-ROOT")] [['Platform ID', 'Safe', 'Target system address','Failure reason']]
Run Code Online (Sandbox Code Playgroud)
其次,有没有办法像我一样在数据框中使用通配符
data['Safe'].str.startswith("CDS-NOI-DEFAULT-UNIX-ROOT")我想在哪里使用data['Safe'].str.startswith("CDS-*DEFAULT-UNIX-ROOT")
这可能吗。
我正在尝试首先根据条件列选择以及>=条件。
[root@elastic_dev ~]# curl -s -XGET http://127.0.0.1:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open fx-syslog-2019.02.12 jbv1mtuET3e8ps2jrJfpjQ 5 1 25964532 0 19.2gb 9.6gb
green open fx-syslog-2019.02.20 _XwyMsX2RWmPkeh8osWrwQ 5 1 16760019 0 3.9gb 1.9gb
green open dfx-syslog-2019.02.13 EfNnTK1lQNm5-SG3DCSqQw 5 1 13378826 0 15.8gb 7.9gb
green open fx-rmlog-2019.02.08 OmA4RlipTLKtd6L73aBUZg 5 1 149320 0 92.3mb 46.2mb
green open dfx-syslog-2019.02.26 Z67qG7XsQJ6AldMSKh9FYw 5 1 2373058 0 709.8mb 355.5mb
green open fx-syslog-2019.02.23 WHDwz10jTWibFfKaAdPT0A 5 1 24857467 0 10.6gb 5.3gb …Run Code Online (Sandbox Code Playgroud)