Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for mcp
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Question | — |
Can pandas be used as a database backend for persistent storage? Question What is the current state of the art database app? How does it compare to SQL? Can pandas be used in place of either? If not, is there something that bridges the gap between SQL and pandas or the current state of the art? Context I have become proficient in pandas and have come to... (more) |
— | 10 months ago |
Answer | — |
A: Remove entries by two-column ID everywhere, that meet a condition somewhere Answer After re-encountering this problem and searching for a solution with a less generic "pandas check if column pair is found in other df" (forgetting I had previously encountered this problem altogether), I found some inspiration that led me to a solid solution. It is fastest, and most c... (more) |
— | 10 months ago |
Question | — |
Remove entries by two-column ID everywhere, that meet a condition somewhere MWE ```py import random import pandas as pd from itertools import product random.seed(12345) dies = [1, 2] cells = list(range(10)) currents = [100, 200, 300] dcc = list(product(dies, cells, currents)) resistances = random.choices(range(250000 + 1), k=len(dcc)) df = pd.DataFra... (more) |
— | about 1 year ago |
Question | — |
How to compress columns of dataframe by function Problem How can I compress each column of a dataframe to the output of a function (i.e., mean), preserving columns? MWE ```py import pandas as pd data = {"A": [1, 2, 3, 4], "B": [5, 6, 7, 8]} df = pd.DataFrame(data) ``` ``` A B 0 1 5 1 2 6 2 3 7 3 4 8 ``` Desired... (more) |
— | about 1 year ago |
Question | — |
Built-in way to compute coefficient of variation in pandas Background The coefficient of variation is: > defined as the ratio of the standard deviation to the mean Question Is there a built-in function for this? Tried I know I can do `df.std() / df.mean()`. (more) |
— | over 1 year ago |
Question | — |
How can I provide additional information when raising an exception? Suppose I have some code like: ```py filename = "baddir" print(f"File not found: {filename}.") raise(FileNotFoundError) ``` When the exception isn't caught, the stack trace is printed at the end of the output, right as the program aborts. The `print`ed message could be far above this and is... (more) |
— | over 1 year ago |
Question | — |
How to plot table from pandas dataframe MWE ```py import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.DataFrame(np.random.rand(9, 4), columns=['a', 'b', 'c', 'd']) df.plot.bar(table=True) # don't want plot, just want table df.plot.table() # what I would hope plt.show() ``` Busy Bar with Table Q... (more) |
— | almost 2 years ago |
Question | — |
How to add vertical lines for visual separation in pandas plot MWE ```py import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.DataFrame(np.random.rand(9, 4), columns=['a', 'b', 'c', 'd']) df.plot.bar() plt.show() ``` Busy Bar Graph Question How do I add separating vertical lines between groups? Say these are groups o... (more) |
— | almost 2 years ago |
Answer | — |
A: How can we grow this community? A note on first impressions: I really like that popup windows like when you click "react" are closed by clicking "react" again, not just anywhere else on the screen. This makes the site feel solid to me, and less prone to error. It also works really well with Vimium where you can't easily selec... (more) |
— | almost 2 years ago |
Question | — |
How to configure .gitignore to ignore all files except a certain directory MWE In the terminal run: ```sh mkdir mwe cd mwe mkdir dir touch f1.txt f2.pdf dir/f1.txt dir/f2.pdf git init . ``` Create a `.gitignore` with: ```gitignore # ignore all !dir/ # except this directory ``` Problem Git doesn't register this and all files are still ignored: `... (more) |
— | almost 2 years ago |