dateutil.tz package apparently missing when using Pandas?

2024/5/20 17:23:54

My python 2.7 code is as follows:

import pandas as pd
from pandas import DataFrameDF_rando = DataFrame([1,2,3])

...and then when I execute, I get a strange error regarding dateutil.tz.

/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/mattobrien/pandas_test.py
No module named dateutil.tz
Traceback (most recent call last):File "/Users/mattobrien/pandas_test.py", line 2, in <module>import pandas as pdFile "/Library/Python/2.7/site-packages/pandas/__init__.py", line 7, in <module>from . import hashtable, tslib, libFile "pandas/tslib.pyx", line 37, in init pandas.tslib (pandas/tslib.c:76999)
ImportError: No module named dateutil.tzProcess finished with exit code 1

Very strange. I checked an indeed dateutil.tz is indeed installed. I uninstalled Pandas and reinstalled it to be sure. No issues there.

Why am I getting this error?

Answer

Needed these 2 lines.

sudo pip install python-dateutil --upgrade

sudo pip install pytz --upgrade

https://en.xdnf.cn/q/73141.html

Related Q&A

Importing SPSS dataset into Python

Is there any way to import SPSS dataset into Python, preferably NumPy recarray format? I have looked around but could not find any answer.Joon

Given a set of points defined in (X, Y, Z) coordinates, interpolate Z-value at arbitrary (X, Y)

Given a set of points in (X, Y, Z) coordinates that are points on a surface, I would like to be able to interpolate Z-values at arbitrary (X, Y) coordinates. Ive found some success using mlab.griddata …

Python multiprocessing speed

I wrote this bit of code to test out Pythons multiprocessing on my computer:from multiprocessing import Poolvar = range(5000000) def test_func(i):return i+1if __name__ == __main__:p = Pool()var = p.map…

Using os.forkpty() to create a pseudo-terminal to ssh to a remote server and communicate with it

Im trying to write a python script that can ssh into remote server and can execute simple commands like ls,cd from the python client. However, Im not able to read the output from the pseudo-terminal af…

Calculating the sum of a series?

This is my assignment and for the life of me i cant seem to think of a way to do it. This is the code I have so far:sum = 0 k = 1 while k <= 0.0001:if k % 2 == 1:sum = sum + 1.0/kelse:sum = sum - 1.…

get all the partitions of the set python with itertools

How to get all partitions of a set? For example, I have array [1, 2, 3]. I need to get [[1], [2], [3]], [[1], [2, 3]], [[2], [1,3]], [[3], [1, 2]], [[1, 2, 3]]. Now, I wrote this code:def neclusters(S…

Installing Python binary modules to a custom location in Windows

Suppose that I want to install a binary module for Python on Windows. Suppose that the module is distributed as a pre-built installer xxx-n.n.n.win32-py2.7.exe, prepared using distutils.My problem is t…

tkinter tkMessageBox html link

I got a tkMEssagebox.showerror showing up in a python tkinter application, when somebody failed to login with the application. Is it possible to have a url link in the tkMessageBox.showerror?ie.tkMess…

How to build a MultiIndex Pandas DataFrame from a nested dictionary with lists

I have the following dictionary.d= {key1: {sub-key1: [a,b,c,d,e]},key2: {sub-key2: [1,2,3,5,8,9,10]}}With the help of this post, I managed to successfully convert this dictionary to a DataFrame.df = pd…

Functions and if - else in python. Mutliple conditions. Codeacademy

Write a function, shut_down, that takes one parameter (you can use anything you like; in this case, wed use s for string).The shut_down function should return "Shutting down..." when it gets …