If you run the following program in VSCode, an error message appears and the graph does not appear.Please let me know if there is a solution.
error
An exception has occurred: TypeError unhashable type: 'numpy.ndarray'
code:
import pandas as pd
df = pd.read_csv("path of csv file")
df.head()
x = [['x']]
y = [['y']]
import matplotlib.pyplot asplt
import seaborn as sns
plt.plot(x,y,'o')
plt.show()
import pandas as pd
import matplotlib.pyplot asplt
df = pd.read_csv("path of csv file")
df.head()
plt.plot(df['x'], df['y'], 'o')
plt.show()
Also, the pandas.DataFrame
class has the pandas.DataFrame.plot —pandas 1.5.2 documentation method, which is used as follows:
import pandas as pd
import matplotlib.pyplot asplt
df = pd.read_csv("path of csv file")
df.head()
df.plot(x='x', y='y',kind='scatter',marker='o')
plt.show()
© 2024 OneMinuteCode. All rights reserved.