我一直在关注 Next.js 网站上的基础教程,当我进入全局样式步骤时,我开始收到以下运行时错误:
ChunkLoadError: Loading chunk node_modules_next_dist_client_dev_noop_js failed.
(error: http://localhost:3000/_next/static/chunks/fallback/node_modules_next_dist_client_dev_noop_js.js)
Run Code Online (Sandbox Code Playgroud)
我完全按照所有步骤操作,当我关闭错误弹出窗口时,该应用程序运行良好。
如果有人能对此提供任何指导,我将不胜感激!
下面的代码:
df = df.drop('market', 1)
Run Code Online (Sandbox Code Playgroud)
生成警告:
FutureWarning:在 pandas 的未来版本中,除了参数“labels”之外,DataFrame.drop 的所有参数都将仅是关键字
market是我们要删除的列,我们将其1作为轴的第二个参数传递(0 表示索引,1 表示列,因此我们传递 1)。
现在我们如何更改这行代码,以便在以后的 pandas / 版本中不再出现问题来解决现在的警告消息?
我正在 React 中制作注册表单并尝试使用 axios API 发送请求。我在代码中没有收到任何错误,但是当我单击注册按钮,然后转到控制台,然后转到网络时,我发现它无法加载响应数据。
我收到的错误是:
无法加载响应数据:未找到具有给定标识符的资源的数据
export class Register extends React.Component {
handleSubmit = e => {
e.preventDefault();
const data = {
first_name: this.firstName,
last_name: this.lastName,
email: this.email,
password: this.password,
password_confirm: this.confirmPassword
};
axios.post('http://localhost:8000/Register', data).then(
res => {
console.log(res)
}
).catch(
err => {
console.log(err);
}
)
};
render() {
return (
<form onSubmit={this.handleSubmit} >
<h3>Sign Up</h3>
<div className="form-group">
<label> First Name</label>
<input type="text" className="form-control" placeholder="First Name"
onChange={e => this.firstName = e.target.value} />
</div>
<div className="form-group">
<label> Last …Run Code Online (Sandbox Code Playgroud) 如果我创建一个数据框
df = data.frame(a=c(1,2,3), b=c(4,5,6))
Run Code Online (Sandbox Code Playgroud)
为什么这段代码
df$z[c(1,2)] = c(7,8)
Run Code Online (Sandbox Code Playgroud)
产生这个错误
Error in `$<-.data.frame`(`*tmp*`, z, value = c(7, 8)) :
replacement has 2 rows, data has 3
Run Code Online (Sandbox Code Playgroud)
这段代码有效吗?
df$z[c(2,3)] = c(7,8)
Run Code Online (Sandbox Code Playgroud)
df
a b z
1 1 4 NA
2 2 5 7
3 3 6 8
Run Code Online (Sandbox Code Playgroud) 我在 Next js 中使用react-leaflet,但是当重新加载页面时显示“窗口未定义”,即使我使用 ssr:false 的动态导入,我在这里看到了其他人提出的这个问题,并尝试了他们提供的答案,但没有成功,还尝试使地图安装在组件之后,但再次没有结果,我的代码:
function ContactPage() {
const MapWithNoSSR = dynamic(() => import('../Map/Map'), {
ssr: false,
})
return (
<div className={styles.map}>
<MapWithNoSSR/>
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
function Map(){
const [markers, setMarkers]= useState([
{cord:[12.3774729,20.446257]},
{cord:[45.3774729,10.45224757]},
{cord:[40.3774729,15.4364757]},
])
<MapContainer center={[12.374729,22.4464757]} zoom={13} scrollWheelZoom={true} style={{height: "100%", width: "100%",zIndex:'1'}}>
<TileLayer
url={`example.com`}
attribution='Map data © <a>Mapbox</a>'
/>
{markers?.map((element,idx)=>{
return <Marker
position={element?.cord}
draggable={true}
animate={true}
key={idx}
>
<Popup>
Test PopUP
</Popup>
</Marker>
})}
</MapContainer>
}}
}
Run Code Online (Sandbox Code Playgroud) 所以我有 python 版本 3.8.12,在尝试构建 cloudrun 应用程序时,我收到错误:
ERROR: gcloud failed to load: module 'collections' has no attribute 'Mapping'
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试再次运行并安装 Gcloud SDK 时,出现错误:
Welcome to the Google Cloud SDK! Traceback (most recent call last): File "/Users/eshanchatty/downloads/./google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
import bootstrapping File "/Users/eshanchatty/Downloads/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 46, in <module>
from googlecloudsdk.core.updater import update_manager File "/Users/eshanchatty/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/updater/update_manager.py", line 39, in <module>
from googlecloudsdk.core.console import progress_tracker File "/Users/eshanchatty/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/console/progress_tracker.py", line 651, in <module>
class _BaseStagedProgressTracker(collections.Mapping): AttributeError: module 'collections' has no attribute 'Mapping'
Run Code Online (Sandbox Code Playgroud)
这是什么原因造成的,我该如何解决这个问题?
pandas dataframe 中有一种apply方法允许应用一些同步功能,例如:
import numpy as np
import pandas as pd
def fun(x):
return x * 2
df = pd.DataFrame(np.arange(10), columns=['old'])
df['new'] = df['old'].apply(fun)
Run Code Online (Sandbox Code Playgroud)
fun2如果必须应用异步函数,执行类似操作的最快方法是什么:
import asyncio
import numpy as np
import pandas as pd
async def fun2(x):
return x * 2
async def main():
df = pd.DataFrame(np.arange(10), columns=['old'])
df['new'] = 0
for i in range(len(df)):
df['new'].iloc[i] = await fun2(df['old'].iloc[i])
print(df)
asyncio.run(main())
Run Code Online (Sandbox Code Playgroud) 当我改变 a 的样式时pandas.DataFrame,例如像这样
# color these columns
color_columns = ['roi', 'percent_of_ath']
(portfolio_df
.style
# color negative numbers red
.apply(lambda v: 'color: red' if v < 0 else 'color: black',
subset=color_columns)
# color selected cols light blue
.apply(lambda s: 'background-color: lightblue',
subset=color_columns))
Run Code Online (Sandbox Code Playgroud)
应用于数据框的样式不是永久性的。
为了让它们粘在一起,我可以将部件的输出分配(portfolio_df ...给同一个数据帧,如下所示:
portfolio_df = (portfolio_df ...
Run Code Online (Sandbox Code Playgroud)
portfolio_df在 Jupyter Notebook 中显示覆盖的内容,我可以看到样式精美的 DataFrame。但是尝试从模块导入的函数内更改样式,我失败了。我在函数中构造 DataFrame,更改样式,从函数返回(现在)样式化的 DataFrame,将其显示在 Jupyter Notebook 中,我看到一个非样式化的 DataFrame。
检查样式操作的返回值的类型
s = (portfolio_df.style.apply(...
我看到这个:
>>> type(s)
pandas.io.formats.style.Styler
Run Code Online (Sandbox Code Playgroud)
所以该操作不会返回一个DataFrame,而是一个...Styler对象。我错误地认为我可以将此返回值重新分配给我的原始 DataFrame,从而覆盖它并使样式更改永久化。
将样式应用于 DataFrame …
我正在寻找 Django 模型字段来呈现 HTML5 范围滑块,例如:
<input type="range" min="1" max="100" value="50">
Run Code Online (Sandbox Code Playgroud)
这个问题接近于Which Django Form Field can Provide me a HTML output of <input type="range" />? 但它要求提供一个表单,我可以在其中搜索 Django Admin 的管理字段。
此外,此讨论还展示了如何在表单中使用 IntegerField 作为范围滑块: https: //code.djangoproject.com/ticket/20674
长话短说,我可以在 Django Admin 中使用表单,还是已经有一个特定的范围字段?
这是我的第一个 Tailwind CSS 项目,从 CDN 开始,但我并不总是有互联网,所以我尝试使用 PostCSS 安装它,并且我使用 Vite 作为我的服务器。
关注了 CodeWithHarry 的这段视频https://www.youtube.com/watch?v=aUunolbb1xU&list=PLu0W_9lII9ahwFDuExCpPFHAK829Wto2O&index=3
我首先启动了该项目
npm init -y
Run Code Online (Sandbox Code Playgroud)
并安装了所需的软件包
npm install -D tailwind postcss autoprefixer vite
Run Code Online (Sandbox Code Playgroud)
然后通过以下方式启动 Tailwind CSS
npx tailwindcss init -p
Run Code Online (Sandbox Code Playgroud)
我还在 input.css 文件中输入了 @tailwind 指令。
但是当我跑的时候:
npm start
Run Code Online (Sandbox Code Playgroud)
我的 vite 服务器向我打招呼时出现以下错误:
npm init -y
Run Code Online (Sandbox Code Playgroud)
我的index.html:
npm install -D tailwind postcss autoprefixer vite
Run Code Online (Sandbox Code Playgroud)
我的 tailwind.config.js:
npx tailwindcss init -p
Run Code Online (Sandbox Code Playgroud)
我的 postcss.config.js:
npm start
Run Code Online (Sandbox Code Playgroud)
我的package.json:
[plugin:vite:css] Loading PostCSS Plugin failed: Cannot find module 'tailwindcss'
Require stack:
- C:\projects\2 Shidhu\twproject\noop.js …Run Code Online (Sandbox Code Playgroud) python ×4
dataframe ×3
pandas ×3
reactjs ×3
next.js ×2
autoprefixer ×1
axios ×1
django ×1
gcloud ×1
javascript ×1
npm ×1
postcss ×1
r ×1
tailwind-css ×1
vite ×1