Cutting Strings Pyhton

Advertisements i have a simple ui created with pyqt5 it loads a file, let you choose a outputfolder and creats a new txt file with additonals information. the string of the loaded file is written to self.inputs.filename.text() it looks like "C:/User/Folder/File.txt" later in the application i write into a new file in a specific location.… Read More Cutting Strings Pyhton

Find percent difference between two columns, that share same root name, but differ in suffix

Advertisements My question is somewhat similar to subtracting-two-columns-named-in-certain-pattern I’m having trouble performing operations on columns that share the same root substring, without a loop. Basically I want to calculate a percentage change using columns that end with ‘_PY’ with another column that shares the same name except for the suffix. What’s a possible one line… Read More Find percent difference between two columns, that share same root name, but differ in suffix

type object 'PizzaMenu' has no attribute '_default_manager'

Advertisements I have following error while i try to reach PizzaDetailView on template: AttributeError at /pizza/6/ type object ‘PizzaMenu’ has no attribute ‘_default_manager’. Where is the problem? models.py class PizzaMenu(models.Model): name = models.CharField(max_length=30) description = models.TextField() ingredients = models.CharField(max_length=100) price = models.DecimalField(max_digits=4, decimal_places=2) def __str__(self): return self.name class Meta: ordering = ["price"] views.py from django.views.generic… Read More type object 'PizzaMenu' has no attribute '_default_manager'

Pandas : Create columns based on values of another column if string value from 3rd column

Advertisements My dataframe is this : position labels [58.0, 71.0] ind [137.0, 147.0] pro [170.0, 191.0] pro [nan, nan] NaN [nan, nan] NaN [36.0, 57.0] pro [67.0, 73.0] ind [86.0, 93.0] tar [0.0, 8.0] ind The wanted output is this: ind.position pro.position tar.position [58.0, 71.0] [137.0, 147.0] [170.0, 191.0] [36.0, 57.0] [67.0, 73.0] [86.0, 93.0]… Read More Pandas : Create columns based on values of another column if string value from 3rd column

Pandas : Create new column based on text value of another column

Advertisements This might be very simple question, but here’s my dataframe: id text position labels 0 39088 skin melanoma [58.0, 71.0] indication 1 39088 proteinase [137.0, 147.0] protein 2 39088 plasminogen activator [170.0, 191.0] protein 3 39088 NaN [nan, nan] NaN 4 39088 NaN [nan, nan] NaN 5 39088 proteinase substrates [36.0, 57.0] protein 6… Read More Pandas : Create new column based on text value of another column

Adding a suffix that includes superscript text to axis text in ggplot

Advertisements I want to have my x-axis show the scale with an added "m2" at the end of each axis text using the scales::label_number() function. Reproducible code: tibble(x = 1:10, y = 1:10) |> ggplot(aes(x, y)) + scale_x_continuous(label = scales::label_number(suffix = "m^2")) which gives me "5m^2" (for example) on the x-axis, whereas I want it… Read More Adding a suffix that includes superscript text to axis text in ggplot