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.
Related
Does anyone know the fix for this "pd is not defined"? it seems to be combined with a dying kernel. I'm using Jupyter Notebook.
I had started with these imports and didn't get an error message so I was assuming that pandas was imported successfully
import pandas as pd
import numpy as np
Tried updating my Python version to 3.11
This should not be a python problem. Since import pandas as pd did not fail, you should try print out print(pd) and see where pandas is installed and maybe verify it is is properly installed. It should print out something like lib/python3.x/site-packages/pandas/__init__.py'.
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
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
I have recently tried to work on excel spreadsheets through python, but when I try to import them I get this error:
ImportError: cannot import name 'TYPE_BOOL' from 'openpyxl.cell.cell' (C:\Users\frank\Anaconda3\envs\tsa_course\lib\site-packages\openpyxl\cell\cell.py)
This is my code:
import pandas as pd
import numpy as np
pd.read_excel('C:/Users/frank/OneDrive/Desktop/Random_Files/Lista_misa_mara.xlsx')
I am having no problem reading CSV files, but I don't know why I am having this problem with excel files.
It is also worth mentioning that I have tried to import excel files without success in both my base virtual environment and in another virtual environment that I used for a course where I was constantly importing CSV and sometimes excel files to python.
Also, I have accessed this file:
(C:\Users\frank\Anaconda3\envs\tsa_course\lib\site-packages\openpyxl\cell\cell.py),
which is referenced in the ImportError, and I can see the class called 'TYPE_BOOL' but I don't know why it can't be imported.
Summary: How can I get rid of this 'cannot import name 'TYPE_BOOL'' error when reading an excel file?
OBJECTIVE
Using Jupyter notebooks, import a csv file for data manipulation
APPROACH
Import necessary libraries for statistical analysis (pandas, matplotlib, sklearn, etc.)
Import data set using pandas
Manipulate data
CODE
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
style.use("ggplot")
import pandas as pd
from sklearn.cluster import KMeans
data = pd.read_csv("../data/walmart-stores.csv")
print(data)
ERROR
OSError: File b'../data/walmart-stores.csv' does not exist
FOLDER STRUCTURE
Anconda
env
kmean.ipynb
data
walmart-stores.csv
(other folders [for anaconda env])
(other folders)
QUESTION(S)
The error clearly states that the csv file cannot be found. I imagine it has to do with the project running in an Anaconda environment, but I thought this was the purpose of Anaconda environments in the first place. Am I wrong?
After answering the question, are there any other suggestions on how I should structure my Jupyter Notebooks when using Anaconda?
NOTES: I am new to python, anaconda, and jupyter notebooks so please disregard are naivety/stupidity. Thank you!
Fellow newbie here!
Try removing the "../" from your data location
Change
data = pd.read_csv("../data/walmart-stores.csv")
to
data = pd.read_csv("data/walmart-stores.csv")