- 博客(18)
- 资源 (4)
- 收藏
- 关注
原创 ‘utf-8‘ codec can‘t decode byte 0xb8 in position 0: invalid start byte
# 部分代码如下所示data = pd.read_csv("data.csv", index_col = ["date"])data["现有感染者"] = data["感染者"] - data["死亡"] - data["治愈"]print("data:\n",data)运行时出现错误:'utf-8' codec can't decode byte 0xb8 in position 0: invalid start byte简单来说就是:1、( unicode错误)'utf-8’编解码器无法解
2020-08-31 17:12:54 10022 1
原创 Leetcode每日一题:191.number-of-1-bits(位1的个数)
思路:对于n,每次右移一位,并与n&1,如果结果为1,说明改位为1,res++;代码:class Solution {public: int hammingWeight(uint32_t n) { int k=32; int res=0; while(k--) { if(n&1) { res++; } .
2020-08-28 10:09:28 185 1
原创 Leetcode每日一题:190.reverse-bits(颠倒二进制位)
思路:将ans每次左移一位,移位时与n对应位相与,从而确定ans本次左移的位最终是0还是1,为保证n的位与ans对应,每次也要将n右移一位;代码:uint32_t reverseBits(uint32_t n) { uint32_t ans=0; int i=32; while(i--) { ans<<=1; ans+=n&1; n>>.
2020-08-27 13:19:37 229
原创 Leetcode每日一题:189.rotate-array(旋转数组)
思路:方法一:每次移动1个元素,移动n次,时间复杂度O(n*k),空间复杂度O(1),会超时;void rotate(vector<int> &nums, int k) { int len = nums.size(); k %= n; for (int i = 0; i < k; i++) { int temp = nums[n - 1]; for (int j = n - 1; .
2020-08-25 14:17:52 227 2
原创 caj文献格式转PDF格式
1、首先下载直忘caj文献阅读器:下载地址 (下载7.2版本的即可);2、安装后打开caj文件->文件选项栏中选择打印;3、确定注意起始末尾页正确,点击确定;4、选择PDF文件存放位置,随后开始转换,转换完成;...
2020-08-24 15:10:23 309
原创 Leetcode每日一题:183.customers-who-never-order(从不订购的客户)
思路:将前表和后表按Id=CustomerId进行左连接,这样只需要筛选出Orders.Id 为null的表项即可;代码:# Write your MySQL query statement belowselect Name AS Customersfrom Customers left join Orderson Customers.Id=Orders.CustomerIdwhere Orders.Id is null...
2020-08-24 11:01:58 224
原创 Leetcode每日一题:182.duplicate-emails(查找重复的电子邮箱)
思路:一开始想着,原Person Email减去distinct Email的person剩下的即为重复的电子邮箱,但这样不好实现,于是开始想别的法子;一、让Person进行Group by Email,如果对应每个Email,它的count(Idl)>1,那么这就是个重复的Email;二、让Person自己连接自己,如果出现了a.Id!=b.Id,那么说明出现重复Email;代码:方法一:SELECT Email FROM Person GROUP BY Email HAV.
2020-08-23 09:25:47 542
原创 Leetcode每日一题:181.employees-earning-more-than-their-managers(超过经理收入的员工)
思路:回忆起了SQL语句之后,一道道题就感觉挺容易了,这道题直接就是一个内连接就能解决;代码:# Write your MySQL query statement belowselect e1.Name as Employeefrom Employee e1,Employee e2where e1.ManagerId=e2.Id and e1.Salary>e2.Salary...
2020-08-23 09:08:25 190
原创 Leetcode每日一题:176.second-highest-salary(第二高的薪水)
1.解法一:利用 limit 进行限制 此方法可适用于求第N高的薪水,且数据越复杂,速度优势越明显;limit 的用法为:select * from tableName limit i,n tableName:表名 i:为查询结果的索引值(默认从0开始),当i=0时可省略i n:为查询结果返回的数量 i与n之间使用英文逗号","隔开代码为:select(select distinct salary from employee order by salary desc lim..
2020-08-23 00:17:39 401
原创 Leetcode每日一题:175.组合两个表
刷了这么久,第一次碰到SQL的题,自从复试后便很久没看数据库的书了,迟钝了许久;脑中有个大概的印象,但是写的吞吞吐吐,看了解析瞬间回忆起来了;select FirstName, LastName, City, Statefrom Person left join Addresson Person.PersonId = Address.PersonId...
2020-08-23 00:07:24 220
原创 Leetcode每日一题:172.factorial-trailing-zeroes(阶乘后的0)
思路:这道题有点挑战,开始只知道因子2比因子5多,只需要算因子5即可,后来发现还有25,125等等;随后发现题解中一个通俗易懂的帖子,借以参考:int trailingZeroes(int n){ int res = 0; while (n > 0) { res += n / 5; n /= 5; } return res;}...
2020-08-22 10:23:44 180
原创 Leetcode每日一题:171.excel-sheet-column-number(Excel表列序号)
思路:就是168题的反命题,进制的方式完美解决;Leetcode每日一题:168.excel-sheet-column-title(Excel表名称)class Solution {public: int titleToNumber(string s) { int len = s.size(); if (len == 0) return 0; int fac = len - 1; int res.
2020-08-21 13:45:58 209
原创 Leetcode每日一题:169.majority-element(多数元素)
思路:根据题意,该数组里有且只有一个多数元素,即为个数最多并且个数大于n/2的元素,可以采取这样的策略:从第一个数开始time=1,遇到相同的就加1,遇到不同的就减1,减到0就重新换这个数开始计数,总能找到最多的那个;、可能遇到这种情况想不通:1,2,1,3,1,4 这样会使得结果变为4而不是1吗?结果肯定还是1,因为一开始res=1,time=1,当经过4时,time明显会–,降低到0,但此时res的值不会变,只有当nums[i]!=res并且time==0的时候才会让res的值发生变化!!! 如果.
2020-08-20 09:52:29 203
原创 Leetcode每日一题:168.excel-sheet-column-title(Excel表名称)
思路:这类似一个特殊的26进制转换,1-26对应’A’-‘Z’,将其减1后,0-25对应‘A’-‘Z’;代码:class Solution {public:string convertToTitle(int n) { string res = ""; if(n==0) return res; int a = 0, b = 0; while (n > 0) { .
2020-08-19 10:51:34 183
原创 pandas错误之: in pandas._libs.hashtable.PyObjectHashTable.get_item
目的:取data的第41行第6个数据运行data[40][5]返回一下错误:File "pandas\_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable. PyObjectHashTable.get_itemFile "pandas\_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable. PyObjectHashTable
2020-08-03 01:34:28 4014
dlib-19.6.0-cp36-cp36m-win_amd64.rar
2021-03-11
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人