文章浏览阅读165次。Introhive中有explode方法,进行单行转多行的操作。pandas也有类似的功能,versionadded:: 0.25.0。直接看个case。Signature: df1.explode(column: Union[str, Tuple], ignore_index: bool = False) -> 'DataFrame'Docstring:Transform each element of a lis......
文章浏览阅读275次。Intro有时候,需要把字符串当做代码执行,看个例子getattrGet a named attribute from an object; getattr(x, ‘y’) is equivalent to x.yimport pandas as pddf=pd.DataFrame({"x":[1,2,3]})getattr(df,"x").count()3getattr(df,“x”)相当......
文章浏览阅读1.4k次。其实这个问题不止遇到一次了,但有时候同样分母为0,结果却直接为nan。对于这两者之间的关系目前我不太清楚。之前遇到该问题都是靠这两行代码莽过去with np.errstate(divide='ignore', invalid='ignore'): for i in onlis......