当前位置: 首页 > wzjs >正文

建设银行新加坡分行网站在线制作图片网站有哪些

建设银行新加坡分行网站,在线制作图片网站有哪些,趣图在线生成网站源码,wordpress登录密码引言 在当今的数据驱动时代,有效地管理和处理数据成为了软件开发中的关键挑战之一。本博客将深入探讨如何使用Python结合SQLite数据库来执行一系列数据处理任务,包括数据库表的创建、数据合并以及针对特定需求的数据优化。特别地,我们将展示…
引言

在当今的数据驱动时代,有效地管理和处理数据成为了软件开发中的关键挑战之一。本博客将深入探讨如何使用Python结合SQLite数据库来执行一系列数据处理任务,包括数据库表的创建、数据合并以及针对特定需求的数据优化。特别地,我们将展示如何通过算法实现对数据的有效压缩,以满足内存限制或提高数据传输效率的需求。

数据库基础操作

首先,我们需要了解一些基本的SQLite数据库操作。以下代码片段展示了如何连接到SQLite数据库并获取指定表的所有列信息:

def get_columns_info(cursor, table_name):cursor.execute(f"PRAGMA table_info({table_name});")return {info[1]: info[2] for info in cursor.fetchall()}

这里,我们定义了一个get_columns_info函数,它接收一个游标对象和一个表名作为参数,并返回该表中所有列的信息(如列名和类型)。

接下来,我们创建了两个简单的表格voc_tablevoc_table0,并分别插入了一些示例数据:

def voc_and_chip_len_to_sql():conn = sqlite3.connect("voc.db")pd.DataFrame({"voc": list(range(0, 1111)), "voc_id": list(range(0, 1111))}).to_sql(con=conn, name="voc_table", if_exists="replace")pd.DataFrame({"chip_len_428": list(range(0, 1111)), "chip_len_53": list(range(0, 1111))}).to_sql(con=conn, name="voc_table0", if_exists="replace")conn.close()
数据合并

为了将多个表的数据合并成一个新的表,我们可以编写如下函数:

def concat_columns_all_table_to_new_table():# 实现细节...

这个过程涉及读取每个表的数据,去除可能存在的索引列,然后横向拼接这些数据框,并最终将其写入新表中。

数据压缩与优化

面对大量数据时,如何有效压缩数据变得尤为重要。下面的函数演示了如何根据给定的条件选择合适的芯片长度,并进一步对数据进行压缩:

def chips_to_new_voc_id(input_array=[1, 2, 3, 5, 6, 8, 9, 10, 13, 14, 17, 12121, 121212121]):# 实现细节...

此函数首先标记输入数组中的连续序列,然后根据不同范围内的数值大小,采用不同的策略对其进行分组和编码,最后生成一个紧凑表示形式。

结论

通过上述步骤,我们不仅能够高效地管理SQLite数据库中的数据,还能运用智能算法对数据进行优化和压缩。这对于提升应用程序性能、减少存储空间消耗具有重要意义。希望这篇博客能为你的数据处理项目提供有价值的参考和灵感。记住,随着数据量的增长,合理设计数据结构和采用先进的压缩技术将成为解决大数据问题的关键所在。

import  pandas as pd
import numpy as np
import sqlite3
# 选择chiplen
import polars  as pldef get_columns_info(cursor, table_name):cursor.execute(f"PRAGMA table_info({table_name});")return {info[1]: info[2] for info in cursor.fetchall()}def  voc_and_chip_len_to_sql():conn=sqlite3.connect("voc.db")# cursor=conn.cursor()pd.DataFrame({"voc":list(range(0,1111)),"voc_id":list(range(0,1111))}).to_sql(con=conn,name="voc_table",if_exists="replace")conn.close()conn=sqlite3.connect("voc.db")# cursor=conn.cursor()pd.DataFrame({"chip_len_428":list(range(0,1111)),"chip_len_53":list(range(0,1111))}).to_sql(con=conn,name="voc_table0",if_exists="replace")conn.close()def concat_columns_all_table_to_new_table():# 在这里开始  conn=sqlite3.connect("voc.db")cursor=conn.cursor()tables = ["voc_table", "voc_table0"]# 收集所有表的列信息all_columns_info = {}for table in tables:all_columns_info.update(get_columns_info(cursor, table))print(all_columns_info)# 创建 cursor.execute("DROP TABLE IF EXISTS merged_voc_table;")conn.commit()create_statement = "CREATE TABLE IF NOT EXISTS merged_voc_table ({});".format(",".join(["{} {}".format(k,v) for k,v in all_columns_info.items() if k!="index"]))print(create_statement)cursor.execute(create_statement)conn.commit()conn.close()conn=sqlite3.connect("voc.db")chunk_size=100for offset in range(0,1111,chunk_size):one_list=[]for table_name in tables:one=pd.read_sql("SELECT * FROM {} LIMIT {} OFFSET {}".format(table_name,chunk_size,offset),con=conn)if "index" in one.columns:one=one.drop("index",axis=1)one_list.append(one)two=pd.concat(one_list,axis=1)two.to_sql(name="merged_voc_table", con=conn, if_exists='append', index=False)cursor=conn.cursor()cursor.execute("select * from merged_voc_table limit 100")print(cursor.fetchall())conn.close()def  src_token_id_to_new_token_id():# 这里开始进行 制作新表了conn=sqlite3.connect("voc.db")# cursor=conn.cursor()# 给定的voc_id列表text_token_id = [2, 21]# 构造SQL查询 query = "SELECT * FROM merged_voc_table WHERE voc_id IN ({})".format(','.join(['?'] * len(text_token_id)))# 使用pandas.read_sql执行查询并将结果加载到DataFrame中chips = pd.read_sql(query, conn, params=text_token_id)# 输出DataFrame# print(df)conn.close()chips=pl.from_pandas(chips)chip_lens=['chip_len_428', 'chip_len_53']selected_chip_len=""for chip_len in chip_lens:chips_count=len(chips.unique(chip_len))if  chips_count*int(chip_len.split("_")[-1])<8192:selected_chip_len=chip_lenbreakchips = chips[selected_chip_len].to_numpy().tolist()chip_len = int(selected_chip_len.split("_")[-1])# 这里就得到了新的表conn=sqlite3.connect("voc.db")# cursor=conn.cursor()# 构造SQL查询 query = "SELECT * FROM merged_voc_table WHERE {} IN ({})".format(selected_chip_len,','.join(['?'] * len(chips)))# 使用pandas.read_sql执行查询并将结果加载到DataFrame中new_voc = pd.read_sql(query, conn, params=text_token_id)# 输出DataFrame# print(df)conn.close()# 进行关联表print(new_voc)new_voc["new_voc_id"]=new_voc.index.valuesnew_voc = pl.from_pandas(new_voc)new_voc = new_voc["voc_id","new_voc_id"]text_token_id = pl.DataFrame({"voc_id":text_token_id})text_token_id=text_token_id.join(new_voc.filter(new_voc["voc_id"].is_in(text_token_id["voc_id"])),on="voc_id",how="left")return text_token_id,chips,chip_len# chips 表示与压缩  表示
# 现在的到了新的 voc_id  chips 与chips len# chips 我们要进行进一步的压缩  使用  一个填充值特殊token  分开前面的是 连续值使用首位表示 后面的是非连续值使用  单独表示
# chips 1位表 ,2位表,    3位表  填充特殊token  chips 1位表 ,2位表,    3位表 
# def mark_continuous_sequences(arr):# Step 1: Sort the array in ascending ordersorted_arr = sorted(arr)# Initialize the result list with zeros, same length as sorted_arrmarks = [0] * len(sorted_arr)# Initialize the current group markercurrent_group = 0# Step 2 and 3: Iterate over the sorted array and mark continuous sequencesfor i in range(1, len(sorted_arr)):if sorted_arr[i] - sorted_arr[i - 1] == 1:# If the difference between consecutive elements is 1, they are continuousmarks[i] = current_groupelse:# If not, increment the group marker and assign it to the current elementcurrent_group += 1marks[i] = current_groupreturn marksdef chips_to_new_voc_id(input_array = [1, 2, 3, 5,6, 8, 9, 10, 13, 14, 17,12121,121212121]):# Example usage  连续性省略 output_marks = mark_continuous_sequences(input_array)output_marks = np.array(output_marks)print(output_marks)  # Output should be [0, 0, 0, 1, 2, 2, 2, 3, 3, 4]# 分位表示  8192   8192**2 8192**3input_array=np.array(input_array)chips_one=input_array<8192chips_two=(8192<=input_array)&(input_array<8192**2)chips_thr=(8192**2<=input_array)&(input_array<8192**3)chips_one_data=input_array[chips_one]chips_one_mark= output_marks[chips_one]range_s1_list=[]s1_list=[]for i in  sorted(set(chips_one_mark)):if chips_one_mark.tolist().count(i)>1:s1=chips_one_data[chips_one_mark==i]range_s1_list.append(s1[0])range_s1_list.append(s1[-1])else:s1=chips_one_data[chips_one_mark==i]s1_list+=s1.tolist()chips_two_data=input_array[chips_two]chips_two_mark= output_marks[chips_two]range_s2_list=[]s2_list=[]if  chips_two_data.size>0:for i in  sorted(set(chips_two_mark)):if chips_two_mark.tolist().count(i)>1:s2=chips_two_data[chips_two_mark==i]range_s2_list.append(s2[0]//8192)range_s2_list.append(s2[0]%8192)range_s2_list.append(s2[-1]//8192)range_s2_list.append(s2[-1]%8192)else:s2=chips_two_data[chips_two_mark==i]for k,v in zip(s2//8192,s2%8192):s2_list+=[k,v]chips_thr_data=input_array[chips_thr]chips_thr_mark= output_marks[chips_thr]range_s3_list=[]s3_list=[]if  chips_thr_data.size>0:for i in  sorted(set(chips_thr_mark)):if chips_thr_mark.tolist().count(i)>1:s3=chips_thr_data[chips_thr_mark==i]range_s3_list.append(s3[0]//8192**2)range_s3_list.append(s3[0]%8192**2//8192)range_s3_list.append(s3[0]%8192**2%8192)range_s3_list.append(s3[-1]//8192**2)range_s3_list.append(s3[-1]%8192**2//8192)range_s3_list.append(s3[-1]%8192**2%8192)else:s3=chips_thr_data[chips_thr_mark==i]for k,v in zip(s3//8192**2,s3%8192**2):s3_list+=[k,v//8192,v%8192]chips=[]if len(range_s1_list)>0:chips+=["1位"]chips+=range_s1_listif len(range_s2_list)>0:chips+=["2位"]chips+=range_s2_listif len(range_s3_list)>0:chips+=["3位"]chips+=range_s3_listchips+=["填充"]if len(s1_list)>0:chips+=["1位"]chips+=s1_listif len(s2_list)>0:chips+=["2位"]chips+=s2_listif len(s3_list)>0:chips+=["3位"]chips+=s3_listreturn chips
print(chips_to_new_voc_id()) 

文章转载自:

http://8flJjKRI.ygrwt.cn
http://BxR5dAbo.ygrwt.cn
http://Tm9HBe29.ygrwt.cn
http://hC9Ve0G7.ygrwt.cn
http://91UclHKh.ygrwt.cn
http://VH4E2WMc.ygrwt.cn
http://tjg3nfcZ.ygrwt.cn
http://Dr61569m.ygrwt.cn
http://R398YAm0.ygrwt.cn
http://m4AzoJpw.ygrwt.cn
http://bH5cYauD.ygrwt.cn
http://vy8KGLpH.ygrwt.cn
http://Ka8yEnsL.ygrwt.cn
http://NhAu4KqQ.ygrwt.cn
http://zaQUl2lH.ygrwt.cn
http://JXQO0h1A.ygrwt.cn
http://ofsg7sZV.ygrwt.cn
http://oNDo9CXS.ygrwt.cn
http://mGf5ZnDa.ygrwt.cn
http://1ClLcg4m.ygrwt.cn
http://KEfDB34B.ygrwt.cn
http://ZWBcvgHG.ygrwt.cn
http://FsxyNxM8.ygrwt.cn
http://AHRwdWzo.ygrwt.cn
http://VN8Cmkmm.ygrwt.cn
http://BH8iFf8s.ygrwt.cn
http://ONem2zEa.ygrwt.cn
http://JhG75wsz.ygrwt.cn
http://KF6QxnbL.ygrwt.cn
http://8NnX75Tc.ygrwt.cn
http://www.dtcms.com/wzjs/690932.html

相关文章:

  • 各省网站备案时长网站推广软文甄选天天软文
  • 营销型网站盈利模式品牌策略有哪些
  • 建设河南分行网站网站建设 小影seo
  • 表格布局网站学校网站建设的难点
  • 男女做那个网站cp网站开发搭建网站多少钱一套
  • 上海黄页企业名录电话做网站需要知道优化吗
  • 云一网站公司谷歌seo优化什么意思
  • 有没有像一起做网店做男装的网站wordpress 点评主题
  • 外包网站制作阿里邮箱注册
  • 怎么建立一个博客网站网站设计规划书例子
  • 溧阳网站设计手机免费自建网站
  • 高薪聘请网站开发工程师南博网站建设
  • 兰州网站建设优化wordpress 五色可选
  • wordpress 显示置顶文章什么是网站流量优化
  • 自己买服务器搭建网站黄页直播免费观看大全网站
  • 网站 固定ip英国做暧小视频网站
  • 深圳网站公司注册网站开发询价单
  • 梅州做网站医药招商网站大全
  • 在公司网站投简历该怎么做长宁房产网站建设
  • 个人网站开发项目报告江西省赣州市中考成绩查询时间
  • 游泳池建设有专门的网站吗快影
  • 2345网站登录做网站是否用数据库
  • 工作室网站建设方案模板网站首页点击中文英文链接 翻译成对应的语言 怎么做
  • 淘客网站做单品类win7怎么重新安装wordpress
  • 上海营销型网站建设平台百度一下百度搜索百度一下
  • 快速建站公司地址河南省新闻联播视频
  • 深圳做手机商城网站wordpress登录qq微信登录界面
  • 做类似猪八戒网的网站网站群建设进度
  • 英国免费做网站为企业策划一次网络营销活动
  • 南三环做网站的公司跳转到另一个网站怎么做