I tried the following:
import pandas as pd
import numpy as np
x=pd.ExcelFile('Energy Indicator.xls')
energy= x.parse(skiprows =17, skip_footer=38))
...
I got the following error message:
FileNotFoundError, no such file or directory.
I think it's best to declare your filepath specification with something like os.path or filedialog from tkinter.
Related
Why i am getting this error? it should be work.Probally i'm missing something from my sight.
Before that same thing happen the for Classes.I tried rewrite and still same.
import tensorflow as tf
import cv2
import os
import matplotlib.pyplot as plt
import numpy as np
img_array = cv2.imread("Training/0/Training_233976.jpg")
img_array.shape
plt.imshow(img_array)
Datadirectory = "Training/"
Classes = ["0","1","2","3","4","5","6"]
for category in Classes:
path = os.path.join(Datadirectory, category)
for img in os.listdir(path):
img_array = cv2.imread(os.path.join(path,img))
plt.imshow(cv2.cvtColor(img_array, cv2.COLOR_BGR2RGB))
plt.show()
break
break
I am formalizing in an answer, all you need to do is add a line at the top
import os
import os
use this at beginning of your code or where you are importing other libraries and codes .
I'm trying to run the following code:
import os
import librosa
import IPython.display as ipd
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import wavfile
import warnings
warnings.filterwarnings("ignore")
train_audio_path = 'train/audio/'
samples, sample_rate = librosa.load(train_audio_path+'yes/0a7c2a8d_nohash_0.wav', sr = 16000)
But get two errors:
Error opening 'train/audio/yes/0a7c2a8d_nohash_0.wav': File contains data in an unknown format
and
NoBackendError:
I've tried downloading ffmpeg and gstreamer to fix the second error but no luck. I'm not sure what to do about the first error as I have imported libraries that should be able to handle .wav files.
Thank you for your help in advance.
I am trying a project as a beginner. It is driving me nuts because I keep getting minor errors that paralyze the whole execution. Here's an error that has been plaguing me.
### SOLUTION
## 1. Introduction of dataset
import pandas as pd
import numpy as np
from sklearn import linear_model
import matplotlib.pyplot as plt
# This lets us see many columns in the output
pd.set_option('display.expand_frame_repr', False)
df = pd.read_csv('data.csv', index_col=0)
Error:
File "C:\ProgramData\Anaconda\Lib\site-packages\pandas\_libs\parsers.cp36-win_amd64.pyd", line 695, in pandas._libs.parsers.TextReader._setup_parser_source
V\000~Ã\000\000ëtA¸P\000\000\000H»Ì\000H
builtins.FileNotFoundError: File b'data.csv' does not exist.
Why do I get this error even though the csv file exists?
You need to provide absolute path for the file.
For example: pd.read_csv("/path/to/the/file/data.csv", ...)
Or if you want to read the file from current directory:
import os
import sys
csv_path = os.path.dirname(os.path.abspath(sys.executable)) + '/data.csv'
df = pd.read_csv(csv_path, index_col=0)
I downloaded this dataset and stored it in a folder called AutomobileDataset.
I cross checked the working directory using:
import pandas as pd
import numpy as np
import os
os.chdir("/Users/madan/Desktop/ML/Datasets/AutomobileDataset")
os.getcwd()
Output:
'/Users/madan/Desktop/ML/Datasets/AutomobileDataset'
Then I tried reading the file using pandas:
import pandas as pd
import numpy as np
import os
os.chdir("/Users/madan/Desktop/ML/Datasets/AutomobileDataset")
os.getcwd()
automobile_data = pd.read_csv("AutomobileDataset.txt", sep = ',',
header = None, na_values = '?')
automobile_data.head()
Output:
---------------------------------------------------------------------------
ParserError: Error tokenizing data. C error: Expected 1 fields in line 2, saw 26
Someone please help me with this, I don't know where I am making a mistake.
Can try this!
import os
# Read in a plain text file
with open(os.path.join("c:user/xxx/xx", "xxx.txt"), "r") as f:
text = f.read()
print(text)
import os
import sys
import numpy as np
import scipy
import pylab
import pymorph
import mahotas
import matplotlib.pyplot as plt
import Image
from scipy import ndimage
from pymorph import regmax
from PIL import Image
path='all_images'
for file in os.listdir(path):
current = os.path.join(path, file)
extension = os.path.splitext(current)[-1]
fileType = extension.upper()
print(current)
if os.path.isfile(current):
img = mahotas.imread(current)
imgf = ndimage.gaussian_filter(img, 8)
pylab.gray()
imgf.save('dnaa.gif')
Can not save file using the below python code. Error: numpy.ndarray object has no attribute 'save'. Can anyone help how to save file using pylab. I guss the last line of the code has some issue.
Use mahotas.imsave('dnaa.gif', imgf) instead. The NumPy array you get from gaussian_filter doesn't have save functionality built in.