Occurence of name in dictionary

I am running into a problem and no clue what to do, as I am new to programming. The situation is as follows, we extracted data from a .txt file with names, children etc. and extracted it into a dictionary. The dictionary is accessed with the name as the key, e.g: # access a single… Read More Occurence of name in dictionary

Vue.js – Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'product')

I’m currently working on an eCommerce app using Django and Vue.js and I am currently trying to find out why my CartItem.vue component is not working. Its suppose to display the product, product price, the number of products selected, and the total price of the number of products selected. <template> <tr> <td> <router-link :to="item.product.get_absolute_url">{{ item.product.name… Read More Vue.js – Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'product')

MyPy fails dataclass argument with optional list of objects type

I’m having trouble getting MyPy to pass my script which contains a dataclass Bar with an optional argument foos that holds a list of Foo objects and defaults to an empty list. Stranger still, adding a method Bar.sum_foos() which iterates through self.foos raises a second MyPy error. Am I misunderstanding how to set the correct… Read More MyPy fails dataclass argument with optional list of objects type

datetime reading a different format from the real value

I’m trying to reformat a datetime pattern on csv’s files: Original date format: DAY/MONTH/YEAR Expected Result: YEAR/MONTH/DAY rows = df[‘clock_now’] is: 22/05/2022 12:16 22/05/2022 12:20 22/05/2022 12:21 22/05/2022 12:44 22/05/2022 12:47 22/05/2022 12:47 22/05/2022 12:51 Here is my complete code: import pandas as pd import datetime filials= [ ‘base.csv’, ‘max.csv’ ] for filial in filials:… Read More datetime reading a different format from the real value

Stop for loop iteration trough a list at a certain point

Basically I want that my for loop stops itself after a certain element in the list is being processed. Here is the code: vids = [ ‘https://www.itatv.com/ita_video.php?viewkey=626de171d928a&#8217;, ‘https://www.itatv.com/ita_video.php?viewkey=6050c75748399&#8217;, ‘https://www.itatv.com/ita_video.php?viewkey=6277dbe97910c&#8217;, ‘https://www.itatv.com/ita_video.php?viewkey=5d660515990ec&pkey=150469821&#8217;, ‘https://www.itatv.com/ita_video.php?viewkey=6201e028e3811&#8217;, ‘https://www.itatv.com/ita_video.php?viewkey=6201e028e3811&#8217;, ‘https://www.itatv.com/ita_video.php?viewkey=60dd6838ce483&#8217;, ] for v in vids: try: vids.remove(v) if ‘&pkey=’ in v: raise StopIteration except StopIteration: break print(vids) The output is: [ ‘https://www.itatv.com/ita_video.php?viewkey=626de171d928a&#8217;,… Read More Stop for loop iteration trough a list at a certain point

I got an error when extracting data from a csv file by pandas

I’m trying to get a signal out of aapl data but i got this error import numpy as np import pandas as pd import matplotlib.pyplot as plt from datetime import datetime apple_stock = pd.read_csv(‘AAPL.csv’) apple_stock = apple_stock.set_index(pd.DatetimeIndex(apple_stock[‘Date’].values)) ma30 = pd.DataFrame() ma30[‘AM’] = apple_stock[‘Adj Close’].rolling(window=30).mean() ma100 = pd.DataFrame() ma100[‘AM’] = apple_stock[‘Adj Close’].rolling(window=100).mean() data = pd.DataFrame() data[‘AAPL’]… Read More I got an error when extracting data from a csv file by pandas

How to get in a superclass full names of all methods in subclasses that start with the same two letters in python

I have number of subclasses all of which have number of methods whose names start with "on.." eg.: def on_index(self): raise NotImplementedError() def on_spiking_intent(self): raise NotImplementedError() def on_no_option(self): raise NotImplementedError() I would like to write a method in the superclass which prints a list of all the "on…" methods of its subclasses and specifies to… Read More How to get in a superclass full names of all methods in subclasses that start with the same two letters in python