Python Forum
created a pandas series instead of pandas DataFrame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
created a pandas series instead of pandas DataFrame
#5
Or you can try call .loc correctly:

>>> import pandas as pd
>>> df = pd.DataFrame({'chars': (*'abc',), 'nums': (*range(3),)})
>>> df
 chars  nums
0     a     0
1     b     1
2     c     2
pandas.core.frame.DataFrame
>>> type(df.loc[0])
<class 'pandas.core.series.Series'>
>>> type(df.loc[[0]])                  # note additional brackets
<class 'pandas.core.frame.DataFrame'>
This and some other examples available in pandas documenation: pandas.DataFrame.loc
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: created a pandas series instead of pandas DataFrame - by perfringo - Aug-30-2019, 09:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Add NER output to pandas dataframe dg3000 0 142 Apr-22-2024, 08:14 PM
Last Post: dg3000
  Parsing and summing time deltas (duration) onto bar + pie charts using pandas - - DRY Drone4four 2 604 Feb-10-2024, 06:04 PM
Last Post: Drone4four
  Pandas hierarchical sum mariostg 1 456 Jan-26-2024, 03:47 PM
Last Post: mariostg
  Pandas keep existing format of Excel AlphaInc 2 1,091 Jan-11-2024, 03:44 AM
Last Post: plonkarchivist
  Grouping in pandas/multi-index data frame Aleqsie 3 698 Jan-06-2024, 03:55 PM
Last Post: deanhystad
  [pandas] TypeError: list indices must be integers or slices, not str but type is int. cspower 4 885 Dec-30-2023, 09:38 AM
Last Post: Gribouillis
  Assigning conditional values in Pandas Scott 3 830 Dec-19-2023, 03:10 AM
Last Post: Larz60+
  HTML Decoder pandas dataframe column mbrown009 3 1,063 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  FutureWarning: Logical ops (and, or, xor) between Pandas objects and dtype-less seque NewBiee 5 1,626 Sep-12-2023, 03:15 PM
Last Post: deanhystad
  [solved] duplication in pandas BSDevo 0 561 Sep-06-2023, 10:47 PM
Last Post: BSDevo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020