my code:
annee_now = datetime.datetime.now().strftime("%Y")
dateConstat = fields.Date(default= fields.Date.today())
fiche_emi_Struc=self.env['conformite.fiche'].search_count([(datetime.datetime.strptime(("dateConstat"),"%Y-%m-%d").strftime("%Y"),'=',annee_now)])
my message error:
ValueError: time data 'dateConstat' does not match format '%Y-%m-%d'
How Resolve it?
thanks.
Change the code like this:
annee_now = datetime.datetime.now().strftime("%Y")
dateConstat = fields.Date.today()
fiche_emi_Struc = self.env['conformite.fiche'].search_count([
((dateConstat).strftime("%Y"), '=', annee_now)
])
Related
```if __name__ == "__main__":
pd.options.display.float_format = '{:.4f}'.format
temp1 = pd.read_csv('_4streams_alabama.csv.gz')
temp1['date'] = pd.to_datetime(temp1['date'])
def vacimpval(x):
for date in x['date'].unique():
if date >= '2022-06-16':
x['vac_count'] = x['vac_count'].interpolate()
x['vac_count'] = x['vac_count'].astype(int)
for location in temp1['location_name'].unique():
s = temp1.apply(vacimpval)```
In the code above, I am trying to use this function for all the location so that I can fill in the values using the interpolate method() but I don't know why I keep getting an key error
Source of the error:
Since there are only two places in your code where you access 'date',
and as you said, temp1.columns contains 'date', then the problem is in x['date'].
I want to create VideoWriter with the following code:
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter('out.mp4',fourcc,fps,(frame_width,frame_height))
but i get the error:
TypeError: VideoWriter() missing required argument 'frameSize' (pos 5)
when i change my code to:
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(filename='out.mp4',fourcc=fourcc,fps=fps,frameSize=(frame_width,frame_height))
i get another error:
TypeError: VideoWriter() missing required argument 'apiPreference' (pos 2)
so i change my code to :
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(filename='out.mp4',apiPreference=0,fourcc=fourcc,fps=fps,frameSize=(frame_width,frame_height))
i get error:
TypeError: VideoWriter() missing required argument 'params' (pos 6)
How could i solve it? Could anyone tell me how to use the api:VideoWriter()?Thanks a lot
ok, the following code works for me :
frame_num = int(Cap.get(cv2.CAP_PROP_FRAME_COUNT))
frame_width = int(Cap.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(Cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(result,fourcc,fps,(frame_width,frame_height))
the type of Cap.get(cv2.*) is float, so i change it to integer
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter(path,apiPreference = 0,fourcc = fourcc, fps = 30,frameSize = (256,256) )
for i in range(len(predictions)):
out.write((img_as_ubyte(predictions[i])))
out.release()
it did worked for me
used skimage's image_as_ubyte to convert float to int.
Hi there this is my code:
When I try to run this I get an error.
df = pd.read_csv(file, sep='|', encoding='latin-1')
arreglox = df[df.columns['id':'date_in':'date_out':'objetive':'comments']].as_matrix()
arregloy = df[df.columns[1]].as_matrix()
Here is the error:
File "<ipython-input-30-6060fe26b2b1>", line 1
arreglox = df[df.columns['id':'date_in':'date_out':'objetive':'comments']].as_matrix()
^
SyntaxError: invalid syntax
please help me, thank u very much
The syntax is wrong, if you want those columns in that order try this:
arreglox = df[['id','date_in','date_out','objetive','comments']].as_matrix()
I have loaded the MNIST dataset using the following command:
from dataget import data
dataset = data("mnist").get()
How do I convert it to Sklearn-friendly format, i.e. features_train, labels_train, features_test, labels_test?
I have tried "np.loadtxt" but got this error:
ValueError: could not convert string to float: data
I have also tried the following lines of code:
df = next(dataset.training_set.random_batch_dataframe_generator(10))
df
And it has returned this error:
AttributeError: training_set
Please, can someone help me, I have been googling alternative methods but I still receive errors. Thank you!
P.S. Here's another way I've used to obtain the MNIST dataset:
dataset = fetch_mldata('MNIST original')
#E.Z. helped me out with the answer!
features, labels = dataset.data, dataset.target
I then split them into training and test sets using the following lines of code:
msk = np.random.rand(len(features)) < 0.8
mrk = np.random.rand(len(labels)) < 0.8
features_train = features[msk]
features_test = features[~msk]
labels_train = labels[mrk]
labels_test = labels[~mrk]
I am trying to fix a data set using genfromtxt in Python 3.5. But I keep getting the next error:
ndtype = np.dtype(dict(formats=ndtype, names=names))
TypeError: data type not understood
This is the code I'm using. Any help will be appreciated!
names = ["country", "year"]
names.extend(["col%i" % (idx+1) for idx in range(682)])
dtype = "S64,i4" + ",".join(["f18" for idx in range(682)])
dataset = np.genfromtxt(data_file, dtype=dtype, names=names, delimiter=",", skip_header=1, autostrip=2)
dtype = "S64,i4" + ",".join(["f18" for idx in range(682)])
is going to produce something like:
s64,i4f18,f18,f18,f18...
Note the lack of a comma after the i4.