
python编程
飞奔的帅帅
马云给你还花呗
展开
-
RecursionError: maximum recursion depth exceeded while calling a Python object
raceback (most recent call last): File "/usr/lib/python3.6/abc.py", line 184, in __instancecheck__ if subclass in cls._abc_cache:RecursionError: maximum recursion depth exceeded while calling a Python objectException ignored in: 'pandas._libs.lib.c...原创 2021-03-18 01:07:14 · 2036 阅读 · 1 评论 -
pd.read_csv问题
pd.read_csv()重要参数filepath_or_buffer 路径sep=',' 分隔符names=None, 列名names = ["a", "b", "c"]na_values=None, 默认‘’, ‘#N/A’, ‘#N/A N/A’, ‘#NA’, ‘-1.#IND’, ‘-1.#QNAN’, ‘-NaN’, ‘-nan’, ‘1.#IND’, ‘1.#QNAN’, ‘<NA>’, ‘N/A’, ‘NA’, ‘NULL’, ‘NaN’, ‘...原创 2020-11-06 21:17:02 · 387 阅读 · 0 评论 -
ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should u
直接说原因 merge的第二个参数是字符串类型,转化成int一探究竟object and int64 是有位置的,分别是第一个参数和第二个参数df1 = pd.DataFrame({"a":['13', "1", '1', '3'], "b":[1,1,1,1]})df2 = pd.DataFrame({"a":[1, 2, 3, 4]})pd.merge(df1, df2, on='a', how='inner')然后就报错 ValueError: You are tryi...原创 2020-11-06 20:49:52 · 28451 阅读 · 0 评论 -
pd.concat 横向按索引拼接
纵向拼接ignore_index只对纵向拼接有用,忽略索引,重置横向拼接横向拼接默认按索引拼接,如果这是简单横向拼接,合并前需要重置索引。原创 2019-12-11 13:38:37 · 4845 阅读 · 0 评论 -
python 文件的读写csv/txt
总以为自己掌握了txt文件的读写,可真正使用的时候却一直报错。乃集网络之大成,汇四海于心中1 csv 读写读pd.read_csv()写data.to_csv()index=None, header=None2 txt读写分成三步:打开文件 读/写 关闭文件打开文件之后,根据自己的目的,选择读(r),或写(w)读写写文件的时候,要注意只能...原创 2019-11-20 11:35:39 · 162 阅读 · 0 评论 -
无重复字符的最长子串-python
def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ if not s: return 0 temp = set() n = len(s) count = 0 left = 0 res = 0 fo...原创 2019-10-30 13:20:44 · 155 阅读 · 0 评论 -
最大上升子序列和最长上升子序列python
1 最大上升子序列链接:https://www.nowcoder.com/questionTerminal/dcb97b18715141599b64dbdb8cdea3bd来源:牛客网一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的。对于给定的一个序列(a1, a2, ...,aN),我们可以得到一些上升的子序列(ai1, ai2,...原创 2019-10-25 20:34:44 · 1247 阅读 · 1 评论 -
python实现求平方根精确到0.01
def sqrt(a): if a < 0: return -1 i, j = 0, a while i<= j: mid = (i+j)/2 if abs(mid**2-a)<=0.01: return mid elif mid**2-a>0.01: ...原创 2019-10-24 11:16:54 · 2360 阅读 · 2 评论 -
快速幂实现次方
# 实现a的b次幂def power(a, b): if a==0: return -1 if b==0 and a>0: return 1 temp = 1 while b: if b&1: temp *= a a *=a b = b>&...原创 2019-10-23 22:43:01 · 187 阅读 · 0 评论 -
二分查找及其bian'zhong
1、二分查找 java public class binarySearch { public static boolean binarysearch(int[] array,int target) { int low=0; int high=array.length; while(low<=high) { int mid = (low+high)/2;...原创 2019-09-27 15:07:42 · 152 阅读 · 0 评论