database

How to separate the groupedby data in diferent columns of a dataframe?

How to separate the groupedby data in diferent columns of a dataframe? Question: How do i turn this object Name Color Fruit Banana Yellow Fruit Apple Red Fruit Melon Green Car Fiat White Car BMW Black Car NaN NaN In to this? object Name1 Name2 Name3 Color1 Color2 Color3 Fruit Banana Apple Melon Yellow Red …

Total answers: 2

Pandas concat doesn't work 'DataFrame' object has no attribute 'concat' pandas

Pandas concat doesn't work 'DataFrame' object has no attribute 'concat' pandas Question: I am trying ton concat excel files with pandas but I get this error message "AttributeError: ‘DataFrame’ object has no attrctionibute ‘concat’" My code is the following: def action(): all_files = filedialog.askopenfilename(initialdir = "/", multiple=True, title="select", filetypes=( ("all files", "*.*"), ("Excel", "*.xlsx*"))) dossier=filedialog.askdirectory() …

Total answers: 1

Python (pandas) – Count Occurrences in Column

Python (pandas) – Count Occurrences in Column Question: I have a data frame and want to create a new column to count the number of Participants there are in each row. Is there a way to do this? Data: invoice_df Order Id,Date,Meal Id,Company Id,Date of Meal,Participants,Meal Price,Type of Meal 839FKFW2LLX4LMBB,27-05-2016,INBUX904GIHI8YBD,LJKS5NK6788CYMUU,2016-05-31 07:00:00+02:00,[‘David Bishop’],469,Breakfast 97OX39BGVMHODLJM,27-09-2018,J0MMOOPP709DIDIE,LJKS5NK6788CYMUU,2018-10-01 20:00:00+02:00,[‘David Bishop’],22,Dinner …

Total answers: 3

Link Django models together via GenericKey?

Link Django models together via GenericKey? Question: i have the following models: class Team(models.Model): users = models.ManyToManyField("User") class User(AbstractUser): … class Subscription(models.Model): team = models.ForeignKey("Team", on_delete=models.CASCADE) name = models.CharField(max_length=64) class Package(models.Model): name = models.CharField(max_length=64) # packageA, packageB max_activation_number = models.PositiveIntegerField(default=1) class Activation(models.Model): subscription = models.ForeignKey("Subscription", on_delete=models.CASCADE) package = models.ForeignKey("Package", on_delete=models.CASCADE) created = models.DatetimeField() class PackageA(models.Model): …

Total answers: 2

File not found error when copying images from one folder to another

File not found error when copying images from one folder to another Question: I have a text file containing the names of images to be copied from a source folder to a destination folder. The source folder contains several sub-folders as shown below. The images may come from any of these sub-folders. animals (source folder) …

Total answers: 1

Get rid of characters when writing a dataframe to postgress

Get rid of characters when writing a dataframe to postgress Question: I have a large script that saves data to a postgres database. Tell me how can I get rid of [‘ and ‘]. I need the data in the storage to be saved without these characters total.to_csv("C:/Users/…/total_type19.csv", index = False, sep =’;’) conn5 = …

Total answers: 2

how to update sqlite python table Based on match between another table

how to update sqlite python table Based on match between another table Question: I tried to use the following code but it is giving errors: import sqlite3 conn = sqlite3.connect(‘stock.db’) cursor = conn.cursor() conn.execute("UPDATE COMSEC_STOCK SET COMSEC_STOCK.quantity = COMSEC_STOCK.quantity -1 FROM COMSEC_STOCK, Comsec_Out_Temp WHERE COMSEC_STOCK.product_id = Comsec_Out_Temp.product_id") cursor.close() conn.commit() Asked By: user21030066 || Source Answers: …

Total answers: 1

Lambda function operations using groupby.apply() in dataframe

Lambda function operations using groupby.apply() in dataframe Question: I have a DataFrame that looks like this: The code to build it is: data = {‘Position Date’: [‘2022-01-02’, ‘2022-01-02’, ‘2022-01-02’, ‘2022-01-02’, ‘2022-01-03’, ‘2022-01-03’, ‘2022-01-03’, ‘2022-01-03’], ‘Client’: [‘Client 1’, ‘Client 1’, ‘Client 2’, ‘Client 2’, ‘Client 1’, ‘Client 1’, ‘Client 2’, ‘Client 2’], ‘Product’: [‘Product 1’, ‘Product …

Total answers: 2

Making operations with Multindex DataFrame

Making operations with Multindex DataFrame Question: I have a GroupBy Data Frame that is similar to this one: I want to create a column named PL as the difference between the Position of the same Product of the same Client buyed on the same day with the previous day’s position. Also the first dates should …

Total answers: 1