> ## Content Index
> Fetch the complete content index at: https://datascientyst.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# ValueError: DataFrame constructor not properly called! - Pandas
- URL: https://datascientyst.com/valueerror-dataframe-constructor-not-properly-called-pandas/
- Published: 2022-10-18T06:27:17.000Z
- Updated: 2022-10-18T06:27:17.000Z
- Author: John D K
- Tags: Pandas Error

In this tutorial, we'll take a look at the Pandas error:

```
ValueError: DataFrame constructor not properly called!

```

First, we'll create examples of how to produce it.

Next, we'll explain the reason and finally, we'll see how to fix it.

## ValueError: DataFrame constructor not properly called

Let's try to create DataFrame by:

```python
import pandas as pd
df = pd.DataFrame(0)
df = pd.DataFrame('a')

```

All of them result into error:

> ValueError: DataFrame constructor not properly called!

The same will happen if we try to create DataFrame from directly:

```python
class k:
      pass

a = k()
pd.DataFrame(a)

```

## Reason

There are multiple reasons to get error like:

> ValueError: DataFrame constructor not properly called!

### Pass single value

One reason is trying to pass single value and no index:

```python
df = pd.DataFrame('a')

```

this results in:

```
ValueError: DataFrame constructor not properly called!

```

### Object to DataFrame

Sometimes we need to convert object as follows:

```python
class k:
    def __init__(self, name, ):
        self.name = name
        self.num = 0

a = k('test')
pd.DataFrame(a)

```

This is not possible and result in:

```
ValueError: DataFrame constructor not properly called!

```

## Solution - single value

To solve error - **ValueError: DataFrame constructor not properly called** \- when we pass a single value we need to use a list - add square brackets around the value. This will convert the input vector value:

```python
import pandas as pd
df = pd.DataFrame(['a'])

```

The result is successfully created DataFrame:

|   | 0 |
| - | - |
| 0 | a |

## Solution - object to DataFrame

To convert object to DataFrame we can follow next steps:

```python
class k:
    def __init__(self, name, ):
        self.name = name
        self.num = 0

a = k('test')

```

To convert object "a" to DataFrame first convert it to JSON data by:

```python
import json

print(json.dumps(a.__dict__))

```

the result is:

```
'{"name": "test", "num": 0}'

```

Next we convert the JSON string to dict:

```python
json.loads(data)

```

result:

```
{'name': 'test', 'num': 0}

```

And finally we create DataFrame by:

```python
pd.DataFrame.from_dict(json.loads(data), orient='index').T

```

the object is converted to Pandas DataFrame:

|   | name | num |
| - | ---- | --- |
| 0 | test | 0   |

## Conclusion

In this article, we discussed error: **ValueError: DataFrame constructor not properly called!** reasons and possible solutions.