https://stackoverflow.com/questions/14808945/check-if-variable-is-dataframe

Use the built-in isinstance() function.

 import pandas as pd

 def f(var):
if isinstance(var, pd.DataFrame):
print "do stuff"
 

<Python>判断变量是否是DataFrame 或者 Series的更多相关文章

  1. python 判断变量是否存在 防止报错

    Python判断变量是否存在 方法一:使用try: ... except NameError: .... try: var except NameError: var_exists = False e ...

  2. python 判断变量是否是 None 的三种写法

    代码中经常会有变量是否为None的判断,有三种主要的写法:第一种是`if x is None`:第二种是 `if not x:`:第三种是`if not x is None`(这句这样理解更清晰`if ...

  3. python判断变量是否为int、字符串、列表、元组、字典等方法

    在实际写程序中,经常要对变量类型进行判断,除了用type(变量)这种方法外,还可以用isinstance方法判断: #!/usr/bin/env pythona = 1b = [1,2,3,4]c = ...

  4. 【Python】Python—判断变量的基本类型

    type() >>> type(123)==type(456) True >>> type(123)==int True >>> type('ab ...

  5. Python 判断变量的类型

    这里有两种方法.type 和isinstance import types aaa = 0 print type(aaa) if type(aaa) is types.IntType: print & ...

  6. [Python]判断变量类型是否为List列表

    用法:isinstance(变量,list) li = [1,2,3] print(type(li)) if isinstance(li,list): print("This is a Li ...

  7. Python—判断变量的基本类型

    type() >>> type(123)==type(456) True >>> type(123)==int True >>> type('ab ...

  8. python 判断变量有没有定义

    ? 1 2 'varname' in locals().keys() 'varname' in  dir()

  9. Python判断变量的数据类型的两种方法

    https://www.cnblogs.com/jessicaxu/p/7727264.html

随机推荐

  1. GE与POST方法区别

    1.用途. GET方法一般用于查询并获取信息,这意味着它是幂等的(对同一个url的多个请求,返回结果完全一样),因为没有修改资源状态,所以它是安全的.而POST一般用于更新资源信息,既不是幂等,也不是 ...

  2. [ Windows BAT Script ] BAT 脚本获取windows权限

    BAT 脚本获取windows权限 @echo off echo I am trying to run as Administrator %1 %2 ver|find "5."&g ...

  3. shell作业控制(后台前台命令)

    ctrl+z暂停命令(任务) fg调回命令    |          fg +id号 bg放在后台持续执行 vmstat 1 &  在后面加上‘&’ 即相当于bg jobs列出当前的 ...

  4. Orangegreenworks封装rpgmakermv

    You’ll get a zip file with a folder called “lib” and a file called greenworks.js. Put both of them o ...

  5. mvc未登录跳转到登录界面

    编写一个mvc控制器基类BaseController , 其继承自controller 重写其OnActionExecuting方法, 在其中检测session值,如果没有,则跳转至登录页面. 如下

  6. iview的table中点击Icon弹Poptip,render函数的写法

    render: (h, params) => { return h('div', [ h('div', [ h('Poptip', { props: { confirm: true, trans ...

  7. VPS高性能虚拟机KVM详解

    1. KVM 介绍 1.0 虚拟化简史 其中,KVM 全称是 基于内核的虚拟机(Kernel-based Virtual Machine),它是Linux 的一个内核模块,该内核模块使得 Linux ...

  8. HDU 2176 取(m堆)石子游戏 (尼姆博奕)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2176 m堆石子,两人轮流取.只能在1堆中取.取完者胜.先取者负输出No.先取者胜输出Yes,然后输出怎 ...

  9. github开源的一些ip解析 ,运营商信息,经纬度 地址 后续开发使用

    https://github.com/wzhe06/ipdatabase  ip解析 https://github.com/flyaction/ipdatabase 比较新 https://githu ...

  10. vue 去掉路由中的#

    在router.js中修改, const router = new VueRouter({ mode: 'history', routes: [...] })