[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
Pandas(数据分析处理库)
导入库 import pandas as pd
(pandas数据结构主要有两种:dataframe,series。series是一维数组,dataframe是二维数组。DataFrame是Pandas中的一个表格型的数据结构,包含有一组有序的列,每列可以是不同的值类型(数值、字符串、布尔型等),DataFrame即有行索引也有列索引,可以被看做是由Series组成的字典。它是一种类似于一维数组的对象,是由一组数据(各种NumPy数据类型)以及一组与之相关的数据标签(即索引)组成。仅由一组数据也可产生简单的Series对象)
1>pd.Series([ ]) 返回数组中的元素和其索引
pd.Series([ ],index=list( )) index将索引替换
2>temp_dict={ }
pd.Series(temp_dict) 返回的是字典中的键和键值(索引和值)
3>df.describe()指定索引
4>pd.read_csv(“文件路径”) 读取文件
pd.read_sql(sql_sentence.connection) connection表示数据库链接
5>df.ndim 数据维度
6>df.index 行索引
df.columns 列索引
7>df.head( ) 显示头部几行,默认5行
8>df.tail( ) 显示末尾几行,默认5行
9>df.info( ) 相关信息概览:行数,列数,列索引,内存
10>df.describe( ) 快速综合统计结果:计数,均值,标准差,最大值,斯夫位数,最小值
11>df.sort_values(by=" ") 对指定的列进行排序
12>df.loc[]通过标签来进行索引
df.iloc[]通过位置来进行索引
13>数值运算:df.corr()求取相关系数;df[‘Age’].value_counts()求取Age这一列中相同数字出现的个数
14>数据透视表:example.pivot(index=’’,columns=’’,values=’’),df.pivot_table(index=’’,columns=’’,values=’’,aggfunc=’’)
15>时间操作:(import datetime)首先得先创建一个时间戳,然后进行相关操作
pd.to_datetime(s),ts.month,ts.dt.month,ts.dt.day,ts.dt.weekend
16>df.assign(ration=)对表格进行添加,等于号后面是需要填入的数据的特征
17>df.replace(np.nan,9,inplace=True) 替换值,数据源的替换
18>pd.cut(x,y)将x以y为区间进行切分
19>df.fillna(4)将缺失值填充为数字4
df.isnull()寻找缺失值
20>字符串操作:
21>df1.sort_index(axis=1)按照列索引的方式进行大小排序
22>df.rename(columns={},index={})对行列标签重命名
df.columns()修改数据的列标签
df.index()修改数据的行标签