polars getting 'PyDataFrame is not defined' error when reading from csv - python

trying to read csv into polars dataframe but getting the following error 'PyDataFrame' is not defined. I installed polars latest version for python 3.8
#basic script to read from csv
import polars as pl
data = pl.read_csv("myfile.csv")
print(type(data))
looks like it's an internal package error? anyone got any solutions or can quickly replicate what i have done to confirm it is a package error

Related

module 'pandas' has no attribute 'json_normalize'

I am trying to run a python program on a raspberry pi. The program uses the pandas library including the 'json_normalize' function. I have tried importing pandas with import pandas, and from pandas.io.json import json_normalize but I still get the error. I am using pandas version 0.23.3. Is it just a version problem or is there something else?
There is a problem with Pandas 0.23.
but, You still can run it with pandas 0.22
check this issue open for this problem

uploading a csv file in pandas python in pycharm

I want to upload a csv file in pandas.
Here is the code :
import pandas as pd
df = pd.read_csv('iris.csv')
print(df)
I tried it with different files, too.
The csv file and the py file are located in the same location,
but every time this error pups up:
AttributeError: partially initialized module 'pandas' has no attribute 'read_csv' (most likely due to a circular import)
I tried the file location in read_cvs() too, but nothing changed.
and i tried uninstalling and reinstalling pandas
and also tried with putting csv file in all files like venv
but nothing changed
i tried the code and the csv file in visual studio code and it worked,
but i want it in pycharm
In your error, it shows that the error is coming from circular imports. Uninstall pandas using pip uninstall pandas and then install it with pip install pandas. Furthermore, read this article on circular imports and how to deal with them.

Python in Atom: Cannot import libraries using the "as" statement [Ubuntu 16.04]

I have a problem using Atom in Ubuntu 16.04 for some Python code I'm working at. I have already installed Script. Every time I try to import pandas as pd the command works, but only takes pandas as name, instead of pd.
Importing data with: pd.read_csv( ... ) thus gives me the following error: NameError: name 'pd' is not defined.
In other editors (such as Spyder) I don't have any problem.
What can I do to fix this?

Reading excel/CSV into python

Running the following code
import pandas as pd
import matplotlib.pylab as plt
df1=pd.read_csv("/Users/ee1.xlsx")
Getting an error back as
ValueError: too many values to unpack
I can't figure out what I'm doing wrong. Going out of my mind to trying to resolve this. I'm running Spyder python 2.7 in Anaconda
you have to open excel file using the following code
import pandas as pd
df1=pd.read_excel("/Users/ee1.xlsx")
Excel files and csv files are different.

AttributeError: module 'pandas' has no attribute '__version__'

Please note, this is not a duplicate question. I'm aware of how to find versions of libraries in python. What's caught my goat is the apparent anomaly when the __version__ command is called in two different ways.
Has anyone faced this before? When I type the following in IDLE, I get the output which specifies the pandas version.
>>>import pandas as pd
>>>print(pd.__version__)
0.22.0
When I put the same two lines of code into a program, save it and run it, I get the following error:
AttributeError: module 'pandas' has no attribute '__version__'
It does not make any sense to me. Appreciate any thoughts on this please.
It sounds like you're not importing the real pandas module when you run your script from a file. When I run your script in a file on my machine it prints the pandas version correctly.
Maybe you have a file called pandas.py or a directory called pandas in your current working directory when you run the script? Or maybe there is a pandas.py or a pandas directory in a directory in your PYTHONPATH environment variable? (Other than the real pandas, that is.) Try running this program and see if the output looks like the proper pandas source file, or something else.
import pandas as pd
print(pd.__file__)

Categories