风吹短裙飘

文章 评论 浏览 26

风吹短裙飘 2025-02-20 12:49:51

我会尝试使用一个名为Pathlib的库,并将其与文件名一起加入。

这是代码的外观:

import pathlib
import pandas as pd

filename = 'SYB64_263_202110_Production, Trade and Supply of Energy.csv'

downloads_folder = pathlib.Path.home() / 'Downloads'
file_path = downloads_folder / filename

df = pd.read_csv(file_path)
df.head()

I would try using a library called pathlib and join it with the filename.

Here is how the code would look like:

import pathlib
import pandas as pd

filename = 'SYB64_263_202110_Production, Trade and Supply of Energy.csv'

downloads_folder = pathlib.Path.home() / 'Downloads'
file_path = downloads_folder / filename

df = pd.read_csv(file_path)
df.head()

根本无法在Jupyter笔记本中读取CSV文件

风吹短裙飘 2025-02-20 12:01:13

也许您需要直接公式来设置输出位。

x=0 or y=0 or z=0   is equivalent to x*y*z = 0

x=1 or y=1 or z=1   is equivalent to (x-1)*(y-1)*(z-1)=0

x=2 or y=2 or z=2   is equivalent to (x-2)*(y-2)*(z-2)=0

让我们映射到位:'c':1'D':0xB10'e':0xB100'f':0xb1000

isc的关系(IS'c'):

if xyz=0 then isc=1 else isc=0

如果公式 https://youtu.be/kadkcgbgk0k?list=plni9xbpdzuamul8htsl6vtopqrrn3hhfpppum

rel = “ 和isc = 1)或(isc = 0))和(isc = 0))

[d]:((x-1)(y-1)(y-1)(z-1)= 0和isc = 2)或(( (xyz = 0和isd = 2)或(isc = 0))和(isc = 0))

...

通过以下逻辑连接这些公式:

  • 逻辑 and 是方程式
  • 逻辑是方程的产物

,您将拥有一个总方程式
express sum,您拥有总和的总公式

,然后总和1是c,sum& 2 is d,sum& 4 is e,sum& 5 is f eft eft

efter the之后,您可以形成预定义的数组。

array [sum] 为您提供字符串。

Maybe you need direct formula for output bits set.

x=0 or y=0 or z=0   is equivalent to x*y*z = 0

x=1 or y=1 or z=1   is equivalent to (x-1)*(y-1)*(z-1)=0

x=2 or y=2 or z=2   is equivalent to (x-2)*(y-2)*(z-2)=0

Let's map to bits: 'c':1 'd':0xb10 'e':0xb100 'f':0xb1000

Relation of isc (is 'c'):

if xyz=0 then isc=1 else isc=0

Use math if formula https://youtu.be/KAdKCgBGK0k?list=PLnI9xbPdZUAmUL8htSl6vToPQRRN3hhFp&t=315

[c]: (xyz=0 and isc=1) or (((xyz=0 and isc=1) or (isc=0)) and (isc=0))

[d]: ((x-1)(y-1)(z-1)=0 and isc=2) or (((xyz=0 and isd=2) or (isc=0)) and (isc=0))

...

Connect these formulas by following logic:

  • logic and is the sum of squares of equations
  • logic or is the product of equations

and you'll have a total equation
express sum and you have total formula of sum

then sum&1 is c, sum&2 is d, sum&4 is e, sum&5 is f

After this you may form predefined array where index of string elements would correspond to ready string.

array[sum] gives you the string.

风吹短裙飘 2025-02-20 09:35:56

您好亲爱的朋友,如果您想放在之后 listile a textfield,您可以返回 itembuilder 然后将您的childeren放在

这里

body: Padding(
  padding: const EdgeInsets.only(top: 24, bottom: 24),
  child: Column(
    children: [
      Expanded(
        child: Column(
          children: [
            ListView.separated(
              shrinkWrap: true,
              itemCount: ...,
              itemBuilder: (context, index) {
                return column(
                  childeren: [
                     ListTile(
                         ...
                        ),
                     textfield(),
                 ],
              );
              },
              separatorBuilder: (context, index) {
                return const Divider();
              },
            ),
          ],
        ),
      ),
      Container(
        color: Colors.red,
        child: TextField(),
      ),
      Padding(
        padding: const EdgeInsets.only(left: 38, right: 38),
        child: PaginationWidget(),
      ),
    ],
  ),
), 

hello dear friend if you want to put after each listile a textfield you can return a column in itembuilder then put your childeren in there

like this

body: Padding(
  padding: const EdgeInsets.only(top: 24, bottom: 24),
  child: Column(
    children: [
      Expanded(
        child: Column(
          children: [
            ListView.separated(
              shrinkWrap: true,
              itemCount: ...,
              itemBuilder: (context, index) {
                return column(
                  childeren: [
                     ListTile(
                         ...
                        ),
                     textfield(),
                 ],
              );
              },
              separatorBuilder: (context, index) {
                return const Divider();
              },
            ),
          ],
        ),
      ),
      Container(
        color: Colors.red,
        child: TextField(),
      ),
      Padding(
        padding: const EdgeInsets.only(left: 38, right: 38),
        child: PaginationWidget(),
      ),
    ],
  ),
), 

如何在ListTile扩展后放置文本字段?

风吹短裙飘 2025-02-20 05:40:29

在格式化中添加额外的参数。

FORMAT = "%(levelname)s:%(name)s:%(message)s:{\"client_id\": %(client_id)s}"
logging.basicConfig(level=logging.DEBUG, format=FORMAT)

Add the extra param in formatter.

FORMAT = "%(levelname)s:%(name)s:%(message)s:{\"client_id\": %(client_id)s}"
logging.basicConfig(level=logging.DEBUG, format=FORMAT)

Loggeradapter不会记录额外的

风吹短裙飘 2025-02-20 04:07:33

最简单的方法是使用多行字符串格式化dict,然后使用json.dumps:

d = {'key1': 'val1', 'key2': """{"key3": ["val3"]}"""}
json.dumps(d) # a new json string
json.loads(d["key2"]) # the obj

Easiest way is to format the dict with multi-line string, then use json.dumps:

d = {'key1': 'val1', 'key2': """{"key3": ["val3"]}"""}
json.dumps(d) # a new json string
json.loads(d["key2"]) # the obj

在Python的同一JSON OBJ中解析JSON String和JSON OBJ

风吹短裙飘 2025-02-19 19:53:08

假设您的文件以 g 开头,并且.csv值以 g 开始(例如)只是一个错别字,问题确实存在于这一行:

            if [(gene == (bc['Gene'])) & (primer == (bc['Reverse_primer']))]:

该行有很多不应该存在的装饰,并且它将始终 emange be be true ,因为该表达的结果总是由于外部 [] ,将成为非空的列表。

但是,即使事实并非如此, gene ==(bc ['gene'])永远不会是 true ,如 gene 该系列不会等于该系列(您想检查中的是否是,而不是等于它)。 & 不做您认为的事情,在这里您要获得布尔逻辑,因此您需要而不是。

因此,可能会尝试这样的尝试:

import re
from os import walk
from pandas import DataFrame, read_csv

folder = "sandbox6"

bc = read_csv("primer_combinations.csv")
exceptions = []
for root, dirs, files in walk(folder):
    for file in files:
        try:
            split_fname = re.split("(\w+)-(\w+\.\d)(_\w+_)(R\d).fastq.gz",file)
            gene,primer = split_fname[1], split_fname[2]
            if gene in bc['Gene'] and primer in bc['Reverse_primer']:
                print(file, gene, primer, 'okay')
            else:
                print(file, gene, primer, 'invalid combination')
                continue
        except Exception as e:
            print(e)
            exceptions += [file]
            continue
print(exceptions)

但是,这也不起作用,因为bc ['gene'] 在您可能期望的基因中都无法正常工作,只需检查<<的值是否<<代码>基因是该系列中的索引,而不是其值。它将失败,因为它不再配对值,它只是试图检查该值是否存在于任一列中(任何组合)。

因此,您可以做到这一点:

import re
from os import walk
from pandas import DataFrame, read_csv

folder = "sandbox6"

bc = read_csv("primer_combinations.csv")
exceptions = []
combinations = set(zip((bc['Gene']), set(bc['Reverse_primer'])))
for root, dirs, files in walk(folder):
    for file in files:
        try:
            split_fname = re.split("(\w+)-(\w+\.\d)(_\w+_)(R\d).fastq.gz", file)
            gene, primer = split_fname[1], split_fname[2]
            if (gene, primer) in combinations:
                print(file, gene, primer, 'okay')
            else:
                print(file, gene, primer, 'invalid combination')
                continue
        except Exception as e:
            print(e)
            exceptions += [file]
            continue
print(exceptions)

这有效。但是,如果您需要处理非常大的文件集合(或经常需要执行此操作),则有一些方法可以重写您的代码,以更有效地利用 pandas 必须提供的内容。但这基本上是对您的代码的完全重写,并且远远超出了问题的范围。

Assuming the fact that your files start with g and your .csv values start with G (e.g. gene1 vs Gene1) is just a typo, the problem is really with this one line:

            if [(gene == (bc['Gene'])) & (primer == (bc['Reverse_primer']))]:

That line has a lot of decoration that should not be there, and it will always be True, since the result of that expression is always going to be a non-empty list, due to the outer [].

However, even if that wasn't the case, gene == (bc['Gene']) will never be True, as gene won't be equal that series (you want to check if it is in the series, not equal to it). And & doesn't do what you think it does, here you're going for boolean logic, so you'd want and instead.

So might try something like this instead:

import re
from os import walk
from pandas import DataFrame, read_csv

folder = "sandbox6"

bc = read_csv("primer_combinations.csv")
exceptions = []
for root, dirs, files in walk(folder):
    for file in files:
        try:
            split_fname = re.split("(\w+)-(\w+\.\d)(_\w+_)(R\d).fastq.gz",file)
            gene,primer = split_fname[1], split_fname[2]
            if gene in bc['Gene'] and primer in bc['Reverse_primer']:
                print(file, gene, primer, 'okay')
            else:
                print(file, gene, primer, 'invalid combination')
                continue
        except Exception as e:
            print(e)
            exceptions += [file]
            continue
print(exceptions)

However, that also doesn't work, since gene in bc['Gene'] doesn't work as you might expect, that just checks if the value of gene is an index in the series, not in its values. And it would fail because it no longer pairs up the values, it just tries to check if the value is present in either column (any combination).

So instead, you could do this:

import re
from os import walk
from pandas import DataFrame, read_csv

folder = "sandbox6"

bc = read_csv("primer_combinations.csv")
exceptions = []
combinations = set(zip((bc['Gene']), set(bc['Reverse_primer'])))
for root, dirs, files in walk(folder):
    for file in files:
        try:
            split_fname = re.split("(\w+)-(\w+\.\d)(_\w+_)(R\d).fastq.gz", file)
            gene, primer = split_fname[1], split_fname[2]
            if (gene, primer) in combinations:
                print(file, gene, primer, 'okay')
            else:
                print(file, gene, primer, 'invalid combination')
                continue
        except Exception as e:
            print(e)
            exceptions += [file]
            continue
print(exceptions)

This works. However, there's ways to rewrite your code that makes more efficient use of what pandas has to offer, if you need to process very large collections of files (or need to do this very often). But that would basically be a complete rewrite of your code, and go well beyond the scope of the question.

在CSV中读取两列,然后行链接

风吹短裙飘 2025-02-19 16:31:18

将失败的检查放入排序回调中(比较项目是否失败的差异)

const markSheet = [{ merit: 1 }, { merit: "Failed" }, { merit: 2 }];
const defineMerit = (markSheet) => {
  return markSheet
    .sort((a, b) => (
      ((a.merit === 'Failed') - (b.merit === 'Failed'))
      || a.merit - b.merit
    ));
};
console.log(defineMerit(markSheet))

或之后逆转过滤器条件并与排序的数组结合

const markSheet = [{ merit: 1 }, { merit: "Failed" }, { merit: 2 }];
const defineMerit = (markSheet) => {
  const sorted = markSheet
    .filter((item) => item.merit !== "Failed")
    .sort((a, b) => a.merit - b.merit);
  return sorted.concat(
    markSheet.filter((item) => item.merit === "Failed")
  );
};
console.log(defineMerit(markSheet))

Put the failed check inside the sort callback (compare the difference of whether an item is Failed or not)

const markSheet = [{ merit: 1 }, { merit: "Failed" }, { merit: 2 }];
const defineMerit = (markSheet) => {
  return markSheet
    .sort((a, b) => (
      ((a.merit === 'Failed') - (b.merit === 'Failed'))
      || a.merit - b.merit
    ));
};
console.log(defineMerit(markSheet))

or reverse the filter condition afterwards and combine with the sorted array

const markSheet = [{ merit: 1 }, { merit: "Failed" }, { merit: 2 }];
const defineMerit = (markSheet) => {
  const sorted = markSheet
    .filter((item) => item.merit !== "Failed")
    .sort((a, b) => a.merit - b.merit);
  return sorted.concat(
    markSheet.filter((item) => item.merit === "Failed")
  );
};
console.log(defineMerit(markSheet))

在JS中排序时,我该如何跳过字符串

风吹短裙飘 2025-02-19 13:31:47

如果您处于 GCC 下语句表达”>类似于lambda的示例。

在平原上,C更加困难,您将不得不处理零终止的VA_ARGS列表和许多黑魔法。另一个选择是使用前处理器,也有缺点,但至少实现更容易:

#define FOR_EACH(list, function, ...)                                            \
do {                                                                             \
    if (list == NULL || list->head == NULL) {                                    \
        break;                                                                   \
    }                                                                            \
    for (linked_list_node* node = list->head; node != NULL; node = node->next) { \
        function(node, __VA_ARGS__);                                             \
    }                                                                            \
} while (0)

void print(linked_list_node *node, int *count)
{
    printf("%d) %d\n", (*count)++, node->value);
}

void concat(linked_list_node *node, const char *str1, const char *str2)
{
    printf("%s %d %s\n", str1, node->value, str2);
}

int main(void)
{
    linked_list_node nodes[] = {{1, &nodes[1]} , {2, &nodes[2]}, {3, NULL}};
    linked_list *list = &(linked_list){3, &nodes[0], &nodes[2]};

    int count = 0;
    FOR_EACH(list, print, &count);
    FOR_EACH(list, concat, "Hi", "by");

    return 0;
}

输出:

0) 1
1) 2
2) 3
Hi 1 by
Hi 2 by
Hi 3 by

If you are under gcc you can achieve that using statement expressions and nested functions, here an example of somtehing similar to a lambda.

In plain c is much more difficult and you would have to deal with NULL-terminated va_args lists and a lot of black magic. Another option is to use the preprocessor, also with its disadvantages, but at least the implementation is easier:

#define FOR_EACH(list, function, ...)                                            \
do {                                                                             \
    if (list == NULL || list->head == NULL) {                                    \
        break;                                                                   \
    }                                                                            \
    for (linked_list_node* node = list->head; node != NULL; node = node->next) { \
        function(node, __VA_ARGS__);                                             \
    }                                                                            \
} while (0)

void print(linked_list_node *node, int *count)
{
    printf("%d) %d\n", (*count)++, node->value);
}

void concat(linked_list_node *node, const char *str1, const char *str2)
{
    printf("%s %d %s\n", str1, node->value, str2);
}

int main(void)
{
    linked_list_node nodes[] = {{1, &nodes[1]} , {2, &nodes[2]}, {3, NULL}};
    linked_list *list = &(linked_list){3, &nodes[0], &nodes[2]};

    int count = 0;
    FOR_EACH(list, print, &count);
    FOR_EACH(list, concat, "Hi", "by");

    return 0;
}

Output:

0) 1
1) 2
2) 3
Hi 1 by
Hi 2 by
Hi 3 by

C |传递具有多个参数作为参数的函数

风吹短裙飘 2025-02-19 10:25:21

我不需要经常这样做。我唯一的情况是使用 redux devtools 与中间软件。

我只是这样做了:

const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

或者您可以做:

让myWindow = window as noy;

,然后 mywindow.myprop ='my value'; >

I don't need to do this very often. The only case I have had was when using Redux DevTools with middleware.

I simply did:

const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

Or you could do:

let myWindow = window as any;

And then myWindow.myProp = 'my value';

您如何在打字稿中的“窗口”上明确设置新属性?

风吹短裙飘 2025-02-19 08:10:10

我认为在您的情况下这应该有效:

import pandas as pd
import matplotlib.pyplot as plt
from celluloid import Camera

data = [{'Channel_No':0, 'Value1': 0, 'Value2': 0, 'Value3': 0, 'Value4': 0, 'Value5': 0}, {'Channel_No':1, 'Value1': 2, 'Value2': 1, 'Value3': 3, 'Value4': 4, 'Value5': 5}, {'Channel_No':2, 'Value1': 4, 'Value2': 2, 'Value3': 6, 'Value4': 8, 'Value5': 10}, {'Channel_No':3, 'Value1': 6, 'Value2': 3, 'Value3': 9, 'Value4': 12, 'Value5': 15}, {'Channel_No':4, 'Value1': 8, 'Value2': 4, 'Value3': 12, 'Value4': 16, 'Value5': 20}, {'Channel_No':5, 'Value1': 10, 'Value2': 5, 'Value3': 15, 'Value4': 20, 'Value5': 25}, {'Channel_No':6, 'Value1': 8, 'Value2': 4, 'Value3': 12, 'Value4': 16, 'Value5': 20}, {'Channel_No':7, 'Value1': 6, 'Value2': 3, 'Value3': 9, 'Value4': 12, 'Value5': 15}, {'Channel_No':8, 'Value1': 4, 'Value2': 2, 'Value3': 6, 'Value4': 8, 'Value5': 10}, {'Channel_No':9, 'Value1': 2, 'Value2': 1, 'Value3': 3, 'Value4': 4, 'Value5': 5}, {'Channel_No':10, 'Value1': 0, 'Value2': 0, 'Value3': 0, 'Value4': 0, 'Value5': 0}]
df = pd.DataFrame(data)

fig = plt.figure()
camera = Camera(fig)

for col in df.columns[1:]:
    plt.plot(df[col])
    camera.snap()
    
animation = camera.animate()
animation.save('animated.gif', writer = 'imagemagick')

”在此处输入图像描述”

I think this should work in your case:

import pandas as pd
import matplotlib.pyplot as plt
from celluloid import Camera

data = [{'Channel_No':0, 'Value1': 0, 'Value2': 0, 'Value3': 0, 'Value4': 0, 'Value5': 0}, {'Channel_No':1, 'Value1': 2, 'Value2': 1, 'Value3': 3, 'Value4': 4, 'Value5': 5}, {'Channel_No':2, 'Value1': 4, 'Value2': 2, 'Value3': 6, 'Value4': 8, 'Value5': 10}, {'Channel_No':3, 'Value1': 6, 'Value2': 3, 'Value3': 9, 'Value4': 12, 'Value5': 15}, {'Channel_No':4, 'Value1': 8, 'Value2': 4, 'Value3': 12, 'Value4': 16, 'Value5': 20}, {'Channel_No':5, 'Value1': 10, 'Value2': 5, 'Value3': 15, 'Value4': 20, 'Value5': 25}, {'Channel_No':6, 'Value1': 8, 'Value2': 4, 'Value3': 12, 'Value4': 16, 'Value5': 20}, {'Channel_No':7, 'Value1': 6, 'Value2': 3, 'Value3': 9, 'Value4': 12, 'Value5': 15}, {'Channel_No':8, 'Value1': 4, 'Value2': 2, 'Value3': 6, 'Value4': 8, 'Value5': 10}, {'Channel_No':9, 'Value1': 2, 'Value2': 1, 'Value3': 3, 'Value4': 4, 'Value5': 5}, {'Channel_No':10, 'Value1': 0, 'Value2': 0, 'Value3': 0, 'Value4': 0, 'Value5': 0}]
df = pd.DataFrame(data)

fig = plt.figure()
camera = Camera(fig)

for col in df.columns[1:]:
    plt.plot(df[col])
    camera.snap()
    
animation = camera.animate()
animation.save('animated.gif', writer = 'imagemagick')

enter image description here

单个图上的多个线图,带有呈现延迟

风吹短裙飘 2025-02-18 20:54:42

您可以实现 onChanges 接口,以检查输入属性的更改,并根据此添加一些逻辑。

export class ProductComponent implements OnInit, OnChanges {

  @Input() set product(value: Product) {
      _product = value;
  }
  
  _attributeType: any;
  @Input() set attributeType(value: any) {
      _attributeType = value; 
  }
 
  ngOnChanges(simpleChange: SimpleChanges) {
    if (this._attributeType && this._product) {
      this.doSomeWorkWhenBothProductAndAttributeTypeAreSet();
    }

    // or check simpleChange to retrieve some informations :
    // - new value
    // - previous value
  }

  doSomeWorkWhenBothProductAndAttributeTypeAreSet() {
  }
}

有关官方文档的更多详细信息

You can implement OnChanges interface in order to check changes on input attributes, and add some logic depending on that.

export class ProductComponent implements OnInit, OnChanges {

  @Input() set product(value: Product) {
      _product = value;
  }
  
  _attributeType: any;
  @Input() set attributeType(value: any) {
      _attributeType = value; 
  }
 
  ngOnChanges(simpleChange: SimpleChanges) {
    if (this._attributeType && this._product) {
      this.doSomeWorkWhenBothProductAndAttributeTypeAreSet();
    }

    // or check simpleChange to retrieve some informations :
    // - new value
    // - previous value
  }

  doSomeWorkWhenBothProductAndAttributeTypeAreSet() {
  }
}

More details on official docs

在Angular中分配多个属性值后调用方法

风吹短裙飘 2025-02-18 14:10:22

⚠️功能组件

我认为,一种超级干净的方法是创建一个自定义挂钩,它提供了将回调传回设置器函数的能力,那么,在此之后精确地采取某些操作将是100%保证国家的更新。

通过查看这篇文章您可以理解如何制作 usestatecallback hook。通过使用 usestatecallback 来定义状态,就像以下内容:

const [count, setCount] = useStateCallback(0);

const handleFooBar = () => {
  setCount(c => c + 1, () => { // The callback function
    // All actions here will be run exactly AFTER the update of the count state
  })
};

⚠️ Functional Components

I believe a super clean way would be to create a custom hook that provides the ability to pass a callback to the setter function, then it would be a 100% guarantee to do some actions exactly after the update of the state.

By taking a look at this post you can understand how to make the useStateCallback hook. Defining a state by using the useStateCallback would be like the following:

const [count, setCount] = useStateCallback(0);

const handleFooBar = () => {
  setCount(c => c + 1, () => { // The callback function
    // All actions here will be run exactly AFTER the update of the count state
  })
};

USESTATE SET方法不是立即反映更改

风吹短裙飘 2025-02-18 13:21:56

503错误表明服务器尚未准备好处理请求。

通过URL传输数据存在一些局限性,基本上是URL的长度
通常,极限是2047个字符,不同的浏览器也有所不同

The 503 error indicate that the server is not ready to handle the request.

There are some limitations for transferring data through URL , basically the length of the URL
In general the limit was 2047 chars and it is different for different browsers

HTTP 503用于一些REST API调用

风吹短裙飘 2025-02-18 11:45:06
exports.example = functions..({
setTimeout(() => {
//Your code
}, "milliseconds here");
});
exports.example = functions..({
setTimeout(() => {
//Your code
}, "milliseconds here");
});

firebase云功能在10秒后运行

风吹短裙飘 2025-02-18 00:28:04

Microsoft give a full and working example of databinding the grid view here. https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control?view=netframeworkdesktop-4.8

There are a lot of examples of exporting data to excel. There is one such tutorial here: http://vb.net-informations.com/excel-2007/vb.net_export_from_database_to_excel.htm

项目SQL Server&#x2B; vb.net

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文