Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm new on Python and I have a problem like this.
I have to represent the results of a survey, with the following values: Positive or Negative.
However, I acted on a sample, so I have to represent also the confidence interval of the results.
My idea is to represent a stacked barchart (in percentage, where clearly the entire bar is the 100%) divided in Positive and Negative, but with a sort of representation of the confidence. Is there someone with a valid code?
For data visualisation using Python I would suggest using the matplotlib library.
For your barchart suggestion maybe have a look at the following barchart example taken from the matplotlib website.
Barchart Example
As a suggestion, if you are looking at showing a comparison of total Positive and Negative values perhaps you should consider using a pie chart. See the following example taken from the matplotlib website again.
Basic Pie Chart Example
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have many dataframes(df) which have multiple varying number of columns and the first column is date, the rest of columns are the data I like to plot. I used df.plot() to plot the lines automatically. It is simple to use panda's plot function directly. However, for example, I like to change the linewidth of the first and 4th line or even only the first line. How to do it in pandas? I know how to do it using matplotlib by looping over each column to plot each line. what about just using pandas's plot function? Thanks
Maybe you can create a list with a fixed lenght size (depending of your DataFrame size):
list_of_line_width = [1] * len(df.columns)
The rest is just changing the size of the lines you are looking for:
list_of_line_width[index_position] = lenght_of_the_line
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to analyse a time series(blue one) that looks like this
As you see it's not seasonal I tried to draw the log of this series and it's look like it's not seasonal to ?!
I wonder what's possible to do to forecast the future
log of ts
Your question means "Do I predict variable Y using variable X (X being the time) assuming Y and X are independant". So short answer is no, you can't.
Now, your affirmation that your data is not cyclical seems like jumping to conclusions imo. You might have complex cycles and hidden dependant variables that might explain part of the variance leaving you with more cyclical residuals.
You could maybe try using a periodogram (there are many Python packages for it) to find important parameters, for example the frequency of your signal.
For regular sampled signals, try:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.periodogram.html
For irregular sampled signals on the other hand, I'd suggest:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lombscargle.html
Hope this helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have to do these with Python, Matplotlib, and Pandas.
read a CSV file separated with "," and decimals
count ALL the lines of the file
plot a bar graph with the values of the column year of the same file
find the expected value of ALL the values of a column
find the quartile (with Python and his libraries).
find the proper sample size.
What I ask you is what are the best methods/functions to do all these things.
The only thing which I have reached to write is this.
pd.read_csv('pandas_tutorial_read.csv', delimiter=';')
Here is a problem very similar to what I have to do.
https://www.dropbox.com/sh/sy7vqq2x2740u9d/AACFap-NPA04znDMNX5W9wdza?dl=0
Thank you!
To read in a csv, you can use this code. Delimiter is not required if input file is comma separated.
df = pd.read_csv('path')
To count all rows, use shape attribute of df.
rows = df.shape[0]
To plot a bar graph use this.
import matplotlib.pyplot as plt
plt.bar(col1,col2)
If you mean regressing value by "expected value" use Imputer. You can find documentation online.
Quantiling can be done like this.
df[col].quantile([0,0.25,0.5,0.75])
Didn't understand what you mean by "sample size".
There are tonnes of documentation and tutorials out there. All the best!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Good morning. I have created a distance matrix in which there are distances between EU regions (NUTS2 level), considering some economic and demographic features. Then I have kept only distances from "Lombardia" (an Italian region) and i have ordered them in ascending order. I got the following data frame:
distance
Lombardia 0.0000000
Emilia-Romagna 0.5471997
Veneto 0.6692634
País Vasco 0.6757556
Piemonte 0.7419351
Toscana 0.7641841
Niedersachsen 0.7910501
Marche 0.8066858
Abruzzo 0.8587898
Hessen 0.8646235
Cataluña 0.8855014
I would like to get a good graphical visualization of this table, a visualization that explains well the distances between the regions. I thought that I could use geographical data (for example a Spatial Polygon DataFrame), in order to obtain a map of Europe divided into regions: I would color similar regions in the same way.
However, I don't know how to get a chart like this.
How can I visualize my data?
I usually use R, but I could use also Python.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Hello dear Python experts:)
From a simulation I got data (course of energy over the time) which I have to fit. When I plot the energy it has a non-periodic oscillating course. There are a bunch of helping function like curve_fit from scipy etc. But you always have to specify a function with which the fit should take place. But I don't know a proper function a priori.
I need something like a Fourier fit to get a function representing the data (like it is possible in MatLab) to later use this function to determine its maxima. Has anyone an idea how to deal with such a problem?
Here is an example course: 2
If you like, you can have a look at the data in a .csv-file: https://1drv.ms/u/s!AuQAmr8-QRJSdzNTzyvWPhUaEnw
I would be very delighted to get some help:-)
Many thanks:-)
Using the Fourier fit in MATLAB you also specify a model (how many sin/cos you want).
For instance "Fourier 2" is:
f(x) = a0 + a1*cos(x*w) + b1*sin(x*w) +
a2*cos(2*x*w) + b2*sin(2*x*w)
Check http://exnumerus.blogspot.nl/2010/04/how-to-fit-sine-wave-example-in-python.html to see how to fit for "Fourier1".
If you really want no model you need to use something like "eureqa", which is free for academic use (http://www.nutonian.com/download/eureqa-desktop-download/).