![](/img/trans.png)
[英]ValueError: x and y must have same first dimension, but have shapes (1, 2) and (2,)
[英]X and Y must have same first dimension, but have shapes (nan,) and (nan,)
我在尝试可视化大型 CSV 文件时收到此错误。 附件是数据文件的头部。 任何建议都会很棒,该文件只是一堆质数以及它们在列表中的位置。 头。 csv 文件也已链接。
https://drive.google.com/file/d/1qHzops9jJeMNPhExmebCCvrNGQjJF8aN/view?usp=sharing
所以我决定用我熟悉的模块以一种简单的方式实现它,请考虑向我们展示你的代码,以便找出哪里出了问题。
import matplotlib.pyplot as plt
import pandas as pd
if __name__=="__main__":
df = pd.read_csv('50_million_primes_0.csv')
X = df.Num
Y = df.Prime
print(Y)
# Plot lines and/or markers to the Axes.
plt.plot(X, Y)
# Set the x axis label of the current axis.
plt.xlabel('Num')
# Set the y axis label of the current axis.
plt.ylabel('Prime')
# Set a title
plt.title('Draw a line.')
# Display the figure.
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.