Warning: session_start(): open(/tmp/sess_1451ccbfe06adc6d7b86d8022054efe4, O_RDWR) failed: Disk quota exceeded (122) in /home/wvyrfnwn/learnshareit.com/wp-content/plugins/learnpress/inc/class-lp-page-controller.php on line 1007

Warning: session_start(): Failed to read session data: files (path: /tmp) in /home/wvyrfnwn/learnshareit.com/wp-content/plugins/learnpress/inc/class-lp-page-controller.php on line 1007

Warning: ftp_nlist() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 420

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_nlist() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 420

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 719

Warning: ftp_nlist() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 420

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_nlist() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 420

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 719

Warning: ftp_mkdir() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 562

Warning: ftp_nlist() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 420

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230

Warning: ftp_pwd() expects parameter 1 to be resource, null given in /home/wvyrfnwn/learnshareit.com/wp-admin/includes/class-wp-filesystem-ftpext.php on line 230
NameError: Name 'pd' Is Not Defined In Python - LearnShareIT

NameError: Name ‘pd’ Is Not Defined In Python

NameError: name ‘pd’ is not defined in Python

You get the “NameError: name ‘pd’ is not defined” in Python, and you don’t know how to fix it. Don’t worry; here, I will show you the simplest and easiest ways to fix this error. Let’s follow this article now.

When does the NameError: name ‘pd’ is not defined in Python happen?

As you know, ‘pd’ stands for pandas. It is a library for working with data, visualization, … and two commonly used data structures are Series, DataFrame, … in Python. This is one of the most used libraries in Python.

This error occurs when you import the pandas‘ library but don’t provide the alias as pd while you import it.

Code example:

# Import pandas
import pandas

# Create a variable store data frame
dataframe = pd.DataFrame({'a': [10, 20], 'b': [30, 40]})

print(dataframe)

Output:

NameError: name 'pd' is not defined

How to fix this error?

Importing pandas provide the alias as pd

Because this error occurs when we don’t provide the alias as pd when we import the pandas library. So, we provide the alias when importing pandas. Follow below:

Code example:

# Import pandas and alias as pd
import pandas as pd

# Create a variable store data frame
dataframe = pd.DataFrame({'a': [10, 20], 'b': [30, 40]})

print(dataframe)

Output:

    a   b
0  10  30
1  20  40

Importing pandas package without an alias

Here, we will call functions directly with the name pandas without an alias as pd. This will fix the error ‘pd’ is not defined because we don’t call the name ‘pd’.

Code example:

# Import pandas without alias as pd
import pandas

# Create a variable store data frame
dataframe = pandas.DataFrame({'a': [10, 20], 'b': [30, 40]})

print(dataframe)

Output:

    a   b
0  10  30
1  20  40

Importing all the functions from pandas

For this situation, you needn’t bother with references to call any elements of pandas. See the syntax below and the code example to understand better.

Syntax:

from pandas import *

Code example:

# Import pandas without alias as pd
from pandas import *

# Create a variable store data frame
dataframe = DataFrame({'a': [10, 20], 'b': [30, 40]})

print(dataframe)

Output:

    a   b
0  10  30
1  20  40

Summary

Above are all solutions I can help you fix the “NameError: name ‘pd’ is not defined” in Python. If you have any questions or concerns, don’t hesitate to leave a comment below. Thanks for reading the article! Have a good day!

Maybe you are interested:

Leave a Reply

Your email address will not be published. Required fields are marked *