![](/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.