Questions tagged [series]

A Series object represents a data series. This may be represented as the SeriesCollection class (Java, C#) or Series class in Python Pandas.

  • A series is not necessarily plotted on a chart; it can store data point values that are used to perform a calculation from which another series is created and then plotted. More info available on MSDN.

  • This tag is also used in the context of questions on [pandas] Series. See the pandas tag wiki for more details.

Also see:

2840 questions
583
votes
8 answers

How to convert index of a pandas dataframe into a column

This seems rather obvious, but I can't seem to figure out how to convert an index of data frame to a column? For example: df= gi ptt_loc 0 384444683 593 1 384444684 594 2 384444686 596 To, df= index1 …
msakya
  • 6,911
  • 5
  • 20
  • 29
324
votes
9 answers

Combining two Series into a DataFrame in pandas

I have two Series s1 and s2 with the same (non-consecutive) indices. How do I combine s1 and s2 to being two columns in a DataFrame and keep one of the indices as a third column?
user7289
  • 25,989
  • 27
  • 64
  • 86
272
votes
11 answers

Keep only date part when using pandas.to_datetime

I use pandas.to_datetime to parse the dates in my data. Pandas by default represents the dates with datetime64[ns] even though the dates are all daily only. I wonder whether there is an elegant/clever way to convert the dates to datetime.date or…
user1642513
156
votes
6 answers

How to get the first column of a pandas DataFrame as a Series?

I tried: x=pandas.DataFrame(...) s = x.take([0], axis=1) And s gets a DataFrame, not a Series.
Yariv
  • 11,431
  • 15
  • 47
  • 72
144
votes
6 answers

Conditional Replace Pandas

I have a DataFrame, and I want to replace the values in a particular column that exceed a value with zero. I had thought this was a way of achieving this: df[df.my_channel > 20000].my_channel = 0 If I copy the channel into a new data frame it's…
BMichell
  • 2,683
  • 3
  • 19
  • 25
134
votes
12 answers

Combine Date and Time columns using python pandas

I have a pandas dataframe with the following columns; Date Time 01-06-2013 23:00:00 02-06-2013 01:00:00 02-06-2013 21:00:00 02-06-2013 22:00:00 02-06-2013 23:00:00 03-06-2013 01:00:00 03-06-2013 …
richie
  • 12,586
  • 15
  • 44
  • 64
114
votes
7 answers

Convert pandas data frame to series

I'm somewhat new to pandas. I have a pandas data frame that is 1 row by 23 columns. I want to convert this into a series? I'm wondering what the most pythonic way to do this is? I've tried pd.Series(myResults) but it complains ValueError: cannot…
user1357015
  • 9,314
  • 16
  • 56
  • 100
113
votes
4 answers

Strings in a DataFrame, but dtype is object

Why does Pandas tell me that I have objects, although every item in the selected column is a string — even after explicit conversion. This is my DataFrame: Int64Index: 56992 entries, 0 to 56991 Data columns…
Xiphias
  • 3,668
  • 4
  • 22
  • 40
105
votes
7 answers

Pandas selecting by label sometimes return Series, sometimes returns DataFrame

In Pandas, when I select a label that only has one entry in the index I get back a Series, but when I select an entry that has more then one entry I get back a data frame. Why is that? Is there a way to ensure I always get back a data frame? In…
jobevers
  • 2,648
  • 4
  • 14
  • 24
103
votes
7 answers

Convert pandas Series to DataFrame

I have a Pandas series sf: email email1@email.com [1.0, 0.0, 0.0] email2@email.com [2.0, 0.0, 0.0] email3@email.com [1.0, 0.0, 0.0] email4@email.com [4.0, 0.0, 0.0] email5@email.com [1.0, 0.0, 3.0] email6@email.com [1.0, 5.0,…
woshitom
  • 3,357
  • 7
  • 27
  • 44
98
votes
6 answers

Pandas: convert categories to numbers

Suppose I have a dataframe with countries that goes as: cc | temp US | 37.0 CA | 12.0 US | 35.0 AU | 20.0 I know that there is a pd.get_dummies function to convert the countries to 'one-hot encodings'. However, I wish to convert them to indices…
sachinruk
  • 7,643
  • 7
  • 34
  • 65
88
votes
5 answers

HighCharts Hide Series Name from the Legend

I try to solve this problem several times and give up. Now, when I have met him again, I decided to ask for some help. I have this code for my Legend: legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y:…
gotqn
  • 36,464
  • 39
  • 145
  • 218
88
votes
1 answer

Get first element of Series without knowing the index

Is that any way that I can get first element of Seires without have information on index. For example,We have a Series import pandas as pd key='MCS096' SUBJECTS=pd.DataFrame({'ID':Series([146],index=[145]),\ …
Hello lad
  • 13,374
  • 29
  • 103
  • 174
83
votes
5 answers

Extract values in Pandas value_counts()

Say we have used pandas dataframe[column].value_counts() which outputs: apple 5 sausage 2 banana 2 cheese 1 How do you extract the values in the order same as shown above from max to min ? e.g: [apple,sausage,banana,cheese]
JamesButterlips
  • 841
  • 1
  • 7
  • 5
83
votes
7 answers

Pandas: change data type of Series to String

I use Pandas 'ver 0.12.0' with Python 2.7 and have a dataframe as below: df = pd.DataFrame({'id' : [123,512,'zhub1', 12354.3, 129, 753, 295, 610], 'colour': ['black', 'white','white','white', 'black',…
Zhubarb
  • 8,409
  • 17
  • 65
  • 100
1
2 3
99 100