# Can DataFrames be distinguished by type?

**URL:** https://discourse.julialang.org/t/can-dataframes-be-distinguished-by-type/85442
**Category:** General Usage
**Tags:** question, multidispatch
**Created:** [August 7, 2022, 6:23pm UTC](https://discourse.julialang.org/t/can-dataframes-be-distinguished-by-type/85442 "2022-08-07T18:23:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [August 7, 2022, 6:23pm UTC](https://discourse.julialang.org/t/can-dataframes-be-distinguished-by-type/85442/1 "2022-08-07T18:23:00Z")

</div>

I would like to have a function call fail or not depending on the type of a DataFrame. I cannot distinguish the DataFrames by column types or size.

For example, I would have two identical functions except for the argument type.

```julia
function foo1(df::DataFrame)
return nrow(df)
end

```

Here T is some other type, but with the same methods as a DataFrame

```julia
function foo2(df::T) 
return nrow(df)
end

```

Then I would create a standard dataframe and use it as an argument for `foo`.

```julia
df1 = DataFrame(:A => [1])
foo2(df1)

```

`foo2` would fail, not because `nrow` is not a method, but because `df1` is of the wrong type

I guess this could be done with the package TypedDelegation.jl but I wonder if there is a simpler way.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [August 7, 2022, 11:31pm UTC](https://discourse.julialang.org/t/can-dataframes-be-distinguished-by-type/85442/2 "2022-08-07T23:31:46Z")

</div>

```julia
function foo2(df :: DataFrame)
    throw(ArgumentError("foo2 do not support arguments of type DataFrame"))
end

```
