pd学习 tesk2

这篇博客主要介绍了Pandas的基础知识,包括文件读取、数据验证和替换函数的使用。作者通过示例展示了如何读取数据的前几行和后几行,探讨了对特定列求和验证Total值的问题,以及在遇到数据替换和排序问题时的解决方法。虽然在过程中遇到了一些困惑,但最终通过查阅手册和参考答案找到了解决方案。
摘要由CSDN通过智能技术生成

pd基础
文件读取
这里基本上说的是指令,所以我就直接拿题目demo

import pandas as pd
import numpy  as np
df = pd.read_csv('pokemon.csv')	

当然,这里可以读取前几行与后几行的指令。通常来说,我一般就是用来看看基本情况而已

df.head(3)

#	Name	Type 1	Type 2	Total	HP	Attack	Defense	Sp. Atk	Sp. Def	Speed
0	1	Bulbasaur	Grass	Poison	318	45	49	49	65	65	45
1	2	Ivysaur	Grass	Poison	405	60	62	63	80	80	60
2	3	Venusaur	Grass	Poison	525	80	82	83	100	100	80
df.tail(5)
	#	Name	Type 1	Type 2	Total	HP	Attack	Defense	Sp. Atk	Sp. Def	Speed
795	719	Diancie	Rock	Fairy	600	50	100	150	100	150	50
796	719	DiancieMega Diancie	Rock	Fairy	700	50	160	110	160	110	110
797	720	Hoop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
在 C# 中使用多线程读取 SQL Server 数据库表中的信息,可以使用以下步骤: 1. 创建一个 SQL 连接对象,并打开连接。 2. 创建一个 SQL 命令对象,并设置 SQL 查询语句。 3. 创建一个 SQL 数据适配器对象,并将 SQL 命令对象作为参数进行设置。 4. 创建一个数据表对象,用于存储查询结果。 5. 创建多个线程对象,并为每个线程分配一个任务。 6. 在每个线程中使用 SQL 数据适配器对象来填充数据表对象。 7. 在主线程中等待所有线程完成任务,并合并所有数据表对象。 下面是示例代码: ```csharp using System; using System.Data.SqlClient; using System.Data; using System.Threading; public class Program { static void Main(string[] args) { string connectionString = "Data Source=serverName;Initial Catalog=databaseName;Integrated Security=True;"; string query = "SELECT * FROM tableName;"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); SqlCommand command = new SqlCommand(query, connection); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable(); Thread[] threads = new Thread[5]; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(() => { adapter.Fill(table); }); threads[i].Start(); } foreach (Thread thread in threads) { thread.Join(); } // Merge all tables DataTable mergedTable = new DataTable(); foreach (DataColumn column in table.Columns) { mergedTable.Columns.Add(column.ColumnName, column.DataType); } foreach (DataRow row in table.Rows) { mergedTable.ImportRow(row); } connection.Close(); } } ``` 在上面的示例代码中,我们使用了 5 个线程来读取数据表中的信息,并将结果存储在一个数据表对象中。最后,我们合并了所有数据表对象,得到了完整的查询结果。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值