概述
DataFrame.convert_objects( convert_dates = True,convert_numeric = False,convert_timedeltas = True,copy = True )
尝试推断对象列的更好dtype。
从版本0.21.0开始不推荐使用。
参数:convert_dates :boolean,默认为True
如果为True,请尽可能转换为日期。如果'coerce',强制转换,不可转换的值变为NaT。
convert_numeric : boolean,默认为False
如果为True,则尝试强制转换为数字(包括字符串),不可转换的值变为NaN。
convert_timedeltas : boolean,默认为True
如果为True,请尽可能转换为timedelta。如果'coerce',强制转换,不可转换的值变为NaT。
copy: boolean,默认为True
如果为True,即使不需要复制也不返回副本(例如,没有进行转换)。注意:这是供内部使用的,不应与现场混淆。
返回:converted: 与输入对象相同
例子,
>>> df = pd.DataFrame({'int_str':['1', '2'], 'real_str':['a', 'b']})
>>> df.convert_objects(convert_numeric=True)
int_str real_str
0 1 a
1 2 b
DataFrame.compound( axis = None,skipna = None,level = None)
返回请求轴的值的复合百分比。
参数:axis :{index(0),columns(1)}
要应用的功能的轴。
skipna : bool,默认为True
计算结果时排除NA / null值。
level: int或level name,默认为None
如果轴是MultiIndex(分层),则沿特定级别计数,折叠为系列。
numeric_only : bool,默认None
仅包含float,int,boolean列。如果为None,将尝试使用所有内容,然后仅使用数字数据。未针对系列实施。
** kwargs
要传递给函数的其他关键字参数。
返回:compounded: Series或DataFrame(如果指定了级别)
例子,>>> import pandas as pd
>>> df = pd.DataFrame({'A': [5, 2], 'B': [4, 8]})
>>> print(df.compound())
A 17
B 44
dtype: int64
最后
以上就是高高画板为你收集整理的pythonconvert函数_Python pandas.DataFrame.convert_objects和compound函数方法的使用的全部内容,希望文章能够帮你解决pythonconvert函数_Python pandas.DataFrame.convert_objects和compound函数方法的使用所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复