随笔分类 -  python数据分析

摘要:from pandas import DataFrame import pandas as pd frame = DataFrame({"k1": ["one"]*3+["two"]*4, "k2": [1, 1, 2, 3, 3, 4, 5]}) # 检查是否重复 frame.duplicated 阅读全文
posted @ 2021-02-23 09:53 OTAKU_nicole 阅读(264) 评论(0) 推荐(0)
摘要:import pandas as pd from pandas import DataFrame df1 = DataFrame([[1.4,2],[7.1,-4.5], [2,3],[0.75,-1.3]], columns=['one','two']) print(df1) df2 = Data 阅读全文
posted @ 2021-02-22 20:29 OTAKU_nicole 阅读(509) 评论(0) 推荐(0)
摘要:import requests from pandas import DataFrame url = "***" payload = '***' headers = { 'Content-Type': 'application/x-www-form-urlencoded' } response = 阅读全文
posted @ 2021-02-20 17:25 OTAKU_nicole 阅读(227) 评论(0) 推荐(0)
摘要:import pandas as pd xls_file = pd.ExcelFile("examples/ex1.xlsx") table = xls_file.parse("Sheet1") print(table) ''' Unnamed: 0 a b c d message 0 0 1 2 阅读全文
posted @ 2021-02-20 17:07 OTAKU_nicole 阅读(268) 评论(0) 推荐(0)
摘要:import pandas as pd frame = pd.read_csv("examples/ex1.csv") print(frame) ''' a b c d message 0 1 2 3 4 hello 1 5 6 7 8 world 2 9 10 11 12 foo ''' #fra 阅读全文
posted @ 2021-02-20 16:14 OTAKU_nicole 阅读(216) 评论(0) 推荐(0)
摘要:AttributeError: 'DataFrame' object has no attribute 'save'frame.save改为frame.to_pickleAttributeError: module 'pandas' has no attribute 'load'pd.load改为p 阅读全文
posted @ 2021-02-20 16:12 OTAKU_nicole 阅读(1973) 评论(0) 推荐(0)
摘要:from urllib.request import urlopen from lxml.html import parse parsed = parse(urlopen("https://www.cnblogs.com/nicole-zhang/")) doc = parsed.getroot() 阅读全文
posted @ 2021-02-20 15:58 OTAKU_nicole 阅读(195) 评论(0) 推荐(0)
摘要:import json from pandas import DataFrame obj = """ {"orderBy":"default","orderWay":"desc","pageNo":1,"pageSize":15,"conditions":[{"name":"aaa","age":2 阅读全文
posted @ 2021-02-20 15:34 OTAKU_nicole 阅读(82) 评论(0) 推荐(0)
摘要:import sys import pandas as pd data = pd.read_csv("examples/ex5.csv") print(data) ''' something a b c d message 0 one 1 2 3.0 4 NaN 1 two 5 6 NaN 8 wo 阅读全文
posted @ 2021-02-20 14:17 OTAKU_nicole 阅读(87) 评论(0) 推荐(0)
摘要:cols 改为 columns 阅读全文
posted @ 2021-02-20 13:38 OTAKU_nicole 阅读(1107) 评论(0) 推荐(0)
摘要:import pandas as pd from pandas import Series result = pd.read_csv("examples/ex6.csv") print(result) ''' one two three four key 0 0.467976 -0.038649 - 阅读全文
posted @ 2021-02-20 11:40 OTAKU_nicole 阅读(161) 评论(0) 推荐(0)
摘要:order 改为 sort_values 阅读全文
posted @ 2021-02-20 11:20 OTAKU_nicole 阅读(243) 评论(0) 推荐(0)
摘要:import pandas as pd df1 = pd.read_csv("examples\ex1.csv") print(df1) ''' a b c d message 0 1 2 3 4 hello 1 5 6 7 8 world 2 9 10 11 12 foo ''' df2 = pd 阅读全文
posted @ 2021-02-20 11:07 OTAKU_nicole 阅读(60) 评论(0) 推荐(0)
摘要:from pandas import Series, DataFrame import numpy as np ser = Series(np.arange(3)) print(ser) ''' 0 0 1 1 2 2 dtype: int64 ''' #print(ser[-1]) # 整数索引会 阅读全文
posted @ 2021-02-15 09:23 OTAKU_nicole 阅读(202) 评论(0) 推荐(0)
摘要:frame.irow(0)改为frame.iloc[0] 阅读全文
posted @ 2021-02-15 09:22 OTAKU_nicole 阅读(1157) 评论(0) 推荐(0)
摘要:ser.iget_value(2)改为ser.iat[2] 阅读全文
posted @ 2021-02-15 09:16 OTAKU_nicole 阅读(127) 评论(0) 推荐(0)
摘要:from pandas import Series import numpy as np data = Series(np.random.randn(10), index=[['a','a','a','b','b','b','c','c','d','d'], [1,2,3,1,2,3,1,2,2,3 阅读全文
posted @ 2021-02-15 08:24 OTAKU_nicole 阅读(123) 评论(0) 推荐(0)
摘要:frame.sortlevel(0)改为 frame.sort_index(0) 阅读全文
posted @ 2021-02-15 07:58 OTAKU_nicole 阅读(174) 评论(0) 推荐(0)
摘要:data.ix[['b','d']] 报错AttributeError: 'Series' object has no attribute 'ix' 改为 data.loc[['b','d']] 阅读全文
posted @ 2021-02-15 05:47 OTAKU_nicole 阅读(51) 评论(0) 推荐(0)
摘要:# pandas使用浮点值NaN(Not a Number)表示浮点和非浮点数组中的缺失数据。 from pandas import Series,DataFrame import pandas as pd import numpy as np string_data = Series(['aard 阅读全文
posted @ 2021-02-13 22:49 OTAKU_nicole 阅读(128) 评论(0) 推荐(0)