我在组织数据框时遇到一些困难。我认为这很简单,但是我对此坚持了太久了:
这是df1:
Output Energy, (Wh/h) Lights (Wh) Lights+Media (Wh) Total Usage (h) \
Hour
1 0.0 0.0 0.0 0.0
2 0.0 0.0 0.0 0.0
3 0.0 0.0 0.0 0.0
4 0.0 0.0 0.0 0.0
5 0.0 0.0 0.0 0.0
Run Code Online (Sandbox Code Playgroud)
我希望将其转置以便于使用:
df2 =df1.T
Run Code Online (Sandbox Code Playgroud)
给我:
Hour 1 2 3 4
Output Energy, (Wh/h) 0.0 0.0 0.0 0.0
Lights (Wh) 0.0 0.0 0.0 0.0
Lights+Media (Wh) 0.0 0.0 0.0 0.0
Total Usage (h) 0.0 0.0 0.0 0.0
Lights (h) 0.0 0.0 0.0 0.0 …Run Code Online (Sandbox Code Playgroud) 我过去常常gray-matter在 nextjs 中编写 Markdown 帖子,但在访问博客帖子中使用的图像时遇到问题。
这是我的getStaticProps
export const getStaticProps: GetStaticProps = async ({ params }) => {
const fileName = fs.readFileSync(`posts/${params.slug}.md`, 'utf-8')
const { data: frontmatter, content } = matter(fileName)
return {
props: {
frontmatter,
content,
},
}
}
Run Code Online (Sandbox Code Playgroud)
在我的公共文件夹中我有:
public
- images
- triangle.jpg
Run Code Online (Sandbox Code Playgroud)
我的博客文章如下所示:
---
# title: 'Home'
metaTitle: 'blah'
metaDesc: 'blah- blah'
date: '2022-09-30'
---
### Blah Blah
blah-de-blah, blah blah blah

Run Code Online (Sandbox Code Playgroud)
我已经阅读了 nextjs 上有关访问静态文件的文档,但是如何使用 markdown 访问它们?
我试图根据索引提取列的最大值.我有这个系列:
Hour Values
1 0
1 3
1 1
2 0
2 5
2 4
...
23 3
23 4
23 2
24 1
24 9
24 2
Run Code Online (Sandbox Code Playgroud)
并且我希望根据索引(小时)添加一个新列"最大值",它将为每个值设置"值"列的最大值:
Hour Values Max Value
1 0 3
1 3 3
1 1 3
2 0 5
2 5 5
2 4 5
...
23 3 4
23 4 4
23 2 4
24 1 9
24 9 9
24 2 9
Run Code Online (Sandbox Code Playgroud)
我可以在excel中做到这一点,但我是熊猫新手.我最接近的是这个沙哑的努力,这是我所拥有的,但我在第一个'='上得到语法错误:
df['Max Value'] = 0
df['Max Value'][(df['Hour'] =1)] = df['Value'].max()
Run Code Online (Sandbox Code Playgroud) 我正在尝试连接两个数据框:
df2:
CU Pmt 2017-02-01
h b 15
h d 12
h a 13
Run Code Online (Sandbox Code Playgroud)
和 df1:
CU Pmt 'Total/Max/Min'
h b 20
h d 23
h a 22
a b 16
a d 13
a a 14
Run Code Online (Sandbox Code Playgroud)
这样df3:
CU Pmt 2017-02-01 2017-02-02
h b 15 20
h d 12 23
h a 13 22
a b NaN 16
a d NaN 13
a a Nan 14
Run Code Online (Sandbox Code Playgroud)
我对两者都使用了 index_col = [0,1] 的多索引
这就是我所拥有的:
date = '2017-02-02'
df1 = pd.read_csv(r'Data\2017-02\2017-02-02\Aggregated\Aggregated_Daily_All.csv', usecols=['CU', 'Parameters', …Run Code Online (Sandbox Code Playgroud) 我试图在if一个 jinja 模板的循环中潜入一个语句:
</table>
<class="container">
<table border ="1">
<caption> BBOXX <caption>
<thead class="thead-inverse">
<tr>
<th>CU Serial</th>
<th>System</th>
<th>Version</th>
<th>Enable Status</th>
</tr>
{% for d in client_data %}
<tr>
<td>{{ d["serial_number"]}} </td>
<td>{{ d["hardware_type"]}} </td>
{% if {{ d["current_enable_flag"]}} == TRUE %}
<td> {{ON}} </td>
{% else %}
<td> {{OFF}} </td>
{% endif %}
</tr>
{% endfor %}
</table>
Run Code Online (Sandbox Code Playgroud)
错误是 TemplateSyntaxError: expected token ':', got '}'
这:应该在哪里?