上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 39 下一页
摘要: df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/BostonHousing.csv', chunksize=50) df2 = pd.DataFrame() for chunk in df: df 阅读全文
posted @ 2020-12-04 10:56 Tracydzf 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 现有Series如下 np_array = np.random.randint(1, 10, 35) 要求转化为7行5列的DataFrame如下图: 解决办法: ser = pd.Series(np_array) df = pd.DataFrame(ser.values.reshape(7,5)) 阅读全文
posted @ 2020-12-04 10:34 Tracydzf 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 求两个Series的相关性 现有两个Series如下: import pandas as pd s1 = pd.Series([.2, .0, .6, .2]) s2 = pd.Series([.3, .6, .0, .1]) 求两个Series的皮尔逊系数 解决方法就是把Series当成是一个向量 阅读全文
posted @ 2020-12-04 09:38 Tracydzf 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 按照指定要求前向填充元素(ffill forward fill) 构建数据如下: import pandas as pd df=pd.DataFrame({"A":[5,3,None,4], "B":[None,2,4,3], "C":[4,3,8,5], "D":[5,4,2,None]}) df 阅读全文
posted @ 2020-12-03 17:23 Tracydzf 阅读(425) 评论(0) 推荐(0) 编辑
摘要: 恢复内容开始 从Series的字符串中过滤出email地址 现有Series如下: emails = pd.Series(['buying books at amazom.com', 'rameses@egypt.com', 'matt@t.co', 'narendra@modi.com']) 解决 阅读全文
posted @ 2020-12-03 15:50 Tracydzf 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 恢复内容开始 计算两个Series之间的均方误差 现有两个Series如下: truth = pd.Series(range(10)) pred = pd.Series(range(10)) + np.random.random(10) 计算两个Series之间的均方误差解决办法: np.mean( 阅读全文
posted @ 2020-12-03 14:40 Tracydzf 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 11 把数据进行cut操作 现有数据ages如下 ages = [20, 22, 25, 27, 21, 23, 37, 31, 61, 45, 41, 32, 101] 想按照[(18, 25] < (25, 35] < (35, 60] < (60, 100]]把该数据进行Categories 阅读全文
posted @ 2020-12-03 11:22 Tracydzf 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 6 取出Series 1中独有的数据 现有两个Series, ser1和ser2 如下 ser1 = pd.Series([1, 2, 3, 4, 5]) ser2 = pd.Series([4, 5, 6, 7, 8]) 取出在ser1中出现,但不在ser2中出现的1,2,3出来 解决方法: se 阅读全文
posted @ 2020-12-03 10:36 Tracydzf 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 1 查看pandas的版本 import numpy as np import pandas as pd print(pd.__version__) 0.24.1 2 如何通过list,numpy array, dict创建series 现有list, numpy array, dict如下: im 阅读全文
posted @ 2020-12-03 09:28 Tracydzf 阅读(639) 评论(0) 推荐(0) 编辑
摘要: 数据量大的情况下,不同的SQL语句,消耗的时间相差很大。按下面方法可以提高查询的效果。 1. select子句中尽量避免使用* 2. where子句比较符号左侧避免函数 3.尽量避免使用or 4.使用limit子句限制返回的数据行数 阅读全文
posted @ 2020-11-21 22:54 Tracydzf 阅读(203) 评论(0) 推荐(0) 编辑
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 39 下一页