![]() # directly plot the dataframe, which uses matplotlib as the back endĪx = df_ot(x='timestamp', marker='. # load the data from the markdown table in the OPĭf2.timestamp = pd.to_datetime(df2.timestamp)ĭf_2015 = df2 The plot method on Series and DataFrame is just a simple wrapper around plt.plot (): If the index consists of dates, it calls gcf ().autofmtxdate () to try to format the x-axis nicely as per above. uses matplotlib as the default plotting backend, and should be used for plotting the dataframe.And df2 is not selected for the desired year. x = (('2015')]) is the cause of the error, because it selects the entire dataframe, not a single column of the dataframe.The typical process should begin with cleaning the data, and then selecting.The 'timestamp' column should first be converted to a datetime dtype with pd.to_datetime, otherwise the datetime x-ticks will not be correctly positioned and formatted. Pandas scatter plot documentation says the argument c can be 'A column name or position whose values will be used to color the marker points according to a colormap.The dataframe looks like this and containts timestamp as the day and cnt as the amount of bicycles rent this day # read the following sample data with TypeError: unhashable type: 'numpy.ndarray' plotting a column denoting time on the same axis as a column denoting distance may not make sense, but plotting two columns which both contain distance on the same axis, is fine. ![]() Whether that makes sense you have to decide for yourself. > 214 for val in omkeys(data):Ģ15 # OrderedDict just iterates over unique values in data.Ģ16 _api.check_isinstance((str, bytes), value=val)Ģ18 # this will only be called so long as convertible is True. You can plot any column against any column you like. I wanted to build a scatterplot using dates that contain '2015' as x axis and 'cnt' parameter that means bicycles rent this day.īut after running the code i get this error Cell In, line 14ġ2 x = (('2015')])įile ~\venv\lib\site-packages\matplotlib\category.py:214, in UnitData.update(self, data) y is an iterable with 'mean' value you calculate repeated so that its length is equal to x, i.e. Path2 = r'C:\Users\bossd\OneDrive\Документы\pipirka.csv' This can done by generating a new ymean from your data, then plotting this on the same plot axis using an additional call to ax.plot (), where: x is the same x used in your scatter plot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |