pj_0001_compare_col_csv
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pathlib
import pandas as pd
print("please input the 1stfile to compare")
csv_from = input()
print("please input the compare column")
from_col = input()
print("please input the 2ndfile to compare")
csv_to = input()
print("please input the compare column")
to_col = input()
print(csv_from)
print(from_col)
print(csv_to)
print(to_col)
#check csv
def _compare_csv():
df_from = pd.read_csv(csv_from)
df_to = pd.read_csv(csv_to)
lcol_from = list(df_from[from_col])
lcol_to = list(df_to[to_col])
print("column size of 1st csv is:", len(lcol_from))
print("column size of 2nd csv is:", len(lcol_to))
s1 = set(lcol_from)
s2 = set(lcol_to)
ss1 = s1 - s2
ss2 = s2 - s1
print("1st csv - 2nd csv is",ss1)
print("2nd csv - 1st csv is",ss2)
# ex
print("get other col item?")
q1 = input()
if q1 == 'no':
return
print("get from col or to col?")
q2 = input()
print("give me a col name")
col_name = input()
if q2 == 'from':
lcol_other = list(df_from[col_name])
ss_other = ss1
lcol_ref = lcol_from
else:
lcol_other = list(df_to[col_name])
ss_other = ss2
lcol_ref = lcol_to
#ex for 1st - 2nd
print("ex col value is:")
lout = []
for i in ss_other:
lout.append(lcol_other[lcol_ref.index(i)])
print("other col items is:", lout)
print("for un_repetition", set(lout))
if __name__ == '__main__':
_compare_csv()
pj_0001_compare_col_csv的更多相关文章
随机推荐
- 视觉十四讲:第十二讲_RGB-D稠密点云
1.点云地图 所谓点云,就是由一组离散的点表示的地图,最基本的点包含x,y,z三维坐标,也可以带有r,g,b的彩色信息. #include <iostream> #include < ...
- 万字长文概述单目3D目标检测算法
一,理论基础-相机与图像 1.1,单目相机介绍 1.2,针孔相机模型 1.3,坐标系间的欧式变换 1.4,世界坐标与像素坐标的转换 1.5,三维旋转:欧拉角.旋转矩阵之间的转换 二,单目3D目标检测概 ...
- 「SHOI2015」脑洞治疗仪
\(\text{Naive Solition}\) 当然是 \(ODT\) 暴力啦 \(Luogu\) 煞费苦心加强了数据,于是就过不了了... 不过 \(LibreOJ\) 上可以过 #includ ...
- JZOJ 2936. 【NOIP2012模拟8.9】逐个击破
题面 各大 \(OJ\) 都有 分析 从结果入手:所有被敌方军团占领的城市都是分开的 而按最小代价删去若干条边,则剩下的图必然是若干个联通子图组成的 那么我们要使花费最小,可以是留下的边最大 并查集合 ...
- CCRD_TOC_2008年第1期
中信国健临床通讯 2008年第1期 目 录 类风湿关节炎 1 一种新型.实用的RA活动度评估方法:完成评估只需三分钟 Fleischmann RM, Schiff MH, Keystone EC, ...
- 大道至简的架构设计思想之:封装(C系架构设计法,sishuok)
一起来看看大道至简的一些基本设计思想,首先我们来看一下什么是封装. 封装:也叫做信息隐藏,或者数据访问保护.放到程序上来讲,就是隐藏类的属性,还有实现细节,仅对外公开一些接口.那么外部,就只能通过这个 ...
- pat乙级1016 部分A+B
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> ...
- js控制关闭layui的switch开关
<input class="switch" type="checkbox" lay-skin="switch" lay-filter= ...
- wwise 音频引擎介绍
https://blog.csdn.net/GJQI12/article/details/108007696
- Linux学习之文件目录指令(部分)
包括了 ls pwd cd mkdir rmdir touch cp rm mv cat echo more less head tail > >>指 ...