随笔分类 -  python

python学习
摘要:https://www.cnblogs.com/zhuochong/p/14675984.html 阅读全文
posted @ 2022-01-04 18:11 ivyJ 阅读(22) 评论(0) 推荐(0)
摘要:def _load_config(file): with open(file, 'r') as f: configs = json.load(f) for config in configs: if 'z' in config: for file in config['zips']: file['a 阅读全文
posted @ 2022-01-04 17:46 ivyJ 阅读(98) 评论(0) 推荐(0)
摘要:https://vimsky.com/examples/usage/python-pandas.Series.map.html https://blog.csdn.net/weixin_38664232/article/details/89048065 https://www.cnblogs.com 阅读全文
posted @ 2021-12-29 17:37 ivyJ 阅读(470) 评论(0) 推荐(0)
摘要:判断是否为null和空字符串ation = ation[(ation['risk_factor_1'].notnull()) & (ation['factor_1'] != "")]python判断字符串是否为空 len(x)==0 or x.isspace() ation['factor_1'] 阅读全文
posted @ 2021-12-23 15:36 ivyJ 阅读(762) 评论(0) 推荐(0)
摘要:df["currency"] = df["currency"].apply(lambda x:x[:-3] if x.endswith('USD') else x) 阅读全文
posted @ 2021-12-23 14:45 ivyJ 阅读(391) 评论(0) 推荐(0)
摘要:sensis['ccy'] = dfflat["currency"].apply( lambda x: True if x in ['USD', 'EUR', 'GBP', 'AUD', 'CAD', 'SEK', 'JPY'] else False)sensis['ten'] = dfflat[' 阅读全文
posted @ 2021-12-23 11:00 ivyJ 阅读(144) 评论(0) 推荐(0)
摘要:df = df[df['RiskWeightCode']!='CHF'] 阅读全文
posted @ 2021-12-23 10:57 ivyJ 阅读(1719) 评论(0) 推荐(0)
摘要:merge_cols = ['risk_factor' pd.merge(sensis, self.risk_weights.loc[self.risk_weights['risk_type'] == self.risk_type, merge_cols + ['risk_weight']], on 阅读全文
posted @ 2021-12-22 19:25 ivyJ 阅读(50) 评论(0) 推荐(0)
摘要:df = pd.DataFrame({'Team': ['A', 'A', 'B'], 'score': ['90', '80', '80'],'name':['1','2','3']})df = df.groupby("Team")['score'].apply(lambda x:",".join 阅读全文
posted @ 2021-12-20 15:53 ivyJ 阅读(1246) 评论(0) 推荐(0)
摘要:df.rename(columns={'A': 'a', 'B': 'b', 'C': 'c'}, inplace=True) 阅读全文
posted @ 2021-12-17 11:46 ivyJ 阅读(106) 评论(0) 推荐(0)
摘要:分组后,默认会把分组的那列当作索引,如果不想这列当作索引,就可以添加参数如下,设置分组列不要作为索引: grouby()函数可以按照某列分组,其中分组后的某列连成一个数组 增加新列: https://www.cnpython.com/qa/598149 gg = df.groupby(by=['co 阅读全文
posted @ 2021-12-17 10:56 ivyJ 阅读(603) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-12-16 18:29 ivyJ 阅读(77) 评论(0) 推荐(0)
摘要:前提是explode的列必须是个list或者数组。如果是字符串数组用这个方法https://www.cnblogs.com/ivyJ/p/15693477.html先转换为数组 方法一: df['gg_type'] = df.apply(lambda x: list(zip(x['GG'],x['G 阅读全文
posted @ 2021-12-16 18:27 ivyJ 阅读(81) 评论(0) 推荐(0)
摘要:import numpy as np required_input = required_input.replace(np.nan, '')query_result_input = query_result_input.replace(np.nan, '')将指定列toy的空值替换成指定值100:d 阅读全文
posted @ 2021-12-15 22:00 ivyJ 阅读(2360) 评论(0) 推荐(0)
摘要:@classmethoddef setUpClass(self): self.convert = CptyXVAMeasureConvert() 阅读全文
posted @ 2021-12-15 22:00 ivyJ 阅读(68) 评论(0) 推荐(0)
摘要:重置索引后多了一列旧的索引,价格drop=True,把旧的索引列删除 具体可看: https://blog.csdn.net/yasuowjh/article/details/108086687 阅读全文
posted @ 2021-12-15 21:58 ivyJ 阅读(384) 评论(0) 推荐(0)
摘要:打印dataFrame列的具体数据类型,如果是dtype,无论是string还是数组,dtype打印出来都是object类型,要看到object里的数据类型用type(数值)函数for i in range(15):print(type(df.iloc[0, i])) 阅读全文
posted @ 2021-12-15 21:57 ivyJ 阅读(215) 评论(0) 推荐(0)
摘要:打印dataFrame简要摘要df.info(verbose=True),允许冗余信息,显示所有信息打印包含用的索引信息,dtype,占用的内存等 https://www.freesion.com/article/58821075401/ 阅读全文
posted @ 2021-12-15 21:55 ivyJ 阅读(523) 评论(0) 推荐(0)
摘要:DataFrame.index values are different (99.99837 %)[left]: RangeIndex(start=0, stop=61525, step=1)[right]: Int64Index([ 0, 0, 0, 0, 0, 1, 1, 1, 1,1,...1 阅读全文
posted @ 2021-12-15 21:46 ivyJ 阅读(447) 评论(0) 推荐(0)
摘要:1、数组转字符串 #方法1arr = ['a','b']str1 = ''.join(arr)#方法2arr = [1,2,3]#str = ''.join(str(i) for i in arr)#此处str命名与str函数冲突!str2 = ''.join(str(i) for i in arr 阅读全文
posted @ 2021-12-15 21:44 ivyJ 阅读(1310) 评论(0) 推荐(0)