How to convert pandas dataframe to 3D PanelHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How do I list all files of a directory?Selecting multiple columns in a pandas dataframeRenaming columns in pandasDelete column from pandas DataFrame“Large data” work flows using pandasHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandas

Was the Psych theme song written for the show?

Best Ergonomic Design for a handheld ranged weapon

Should 2FA be enabled on service accounts?

Can living where Earth magnetic ore is abundent provide any protection?

Is it unprofessional to mention your cover letter and resume are best viewed in Chrome?

How would a lunar colony attack Earth?

Is it okay for me to decline a project on ethical grounds?

Word for giving preference to the oldest child

Do the books ever say oliphaunts aren’t elephants?

How does Asimov's second law deal with contradictory orders from different people?

Why would anyone ever invest in a cash-only etf?

What is this kind of symbol meant to be?

What is the highest achievable score in Catan

Prepare a user to perform an action before proceeding to the next step

What would the United Kingdom's "optimal" Brexit deal look like?

When encrypting twice with two separate keys, can a single key decrypt both steps?

My employer is refusing to give me the pay that was advertised after an internal job move

Why are we moving in circles with a tandem kayak?

Scam? Checks via Email

What is my clock telling me to do?

Narset, Parter of Veils interaction with Matter Reshaper

How can Paypal know my card is being used in another account?

How do discovery writers hibernate?

Why don't short runways use ramps for takeoff?



How to convert pandas dataframe to 3D Panel


How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How do I list all files of a directory?Selecting multiple columns in a pandas dataframeRenaming columns in pandasDelete column from pandas DataFrame“Large data” work flows using pandasHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandas






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am reading data from a CSV file which contains weather data for a network of buoys situated off the coast of Ireland. it is a time series dataset with hourly readings for each buoy. I want to create a 3D structure where there is a dataframe for each buoy, containing the columns of the weather conditions, indexed by the date and time.



I would like to be able to access the data via the following syntax:



df['column']['anotherColumn']


I'm aware that pandas has a deprecated Panel class, but I can't work out how to do this otherwise.



Any help would be appreciated, thanks!










share|improve this question





















  • 2





    Use a multi level index?

    – Niels Henkens
    Mar 26 at 21:18











  • I'll look into it. I'm new to pandas so yet to work out the finer details, thanks.

    – C. Dunph
    Mar 26 at 21:20

















1















I am reading data from a CSV file which contains weather data for a network of buoys situated off the coast of Ireland. it is a time series dataset with hourly readings for each buoy. I want to create a 3D structure where there is a dataframe for each buoy, containing the columns of the weather conditions, indexed by the date and time.



I would like to be able to access the data via the following syntax:



df['column']['anotherColumn']


I'm aware that pandas has a deprecated Panel class, but I can't work out how to do this otherwise.



Any help would be appreciated, thanks!










share|improve this question





















  • 2





    Use a multi level index?

    – Niels Henkens
    Mar 26 at 21:18











  • I'll look into it. I'm new to pandas so yet to work out the finer details, thanks.

    – C. Dunph
    Mar 26 at 21:20













1












1








1








I am reading data from a CSV file which contains weather data for a network of buoys situated off the coast of Ireland. it is a time series dataset with hourly readings for each buoy. I want to create a 3D structure where there is a dataframe for each buoy, containing the columns of the weather conditions, indexed by the date and time.



I would like to be able to access the data via the following syntax:



df['column']['anotherColumn']


I'm aware that pandas has a deprecated Panel class, but I can't work out how to do this otherwise.



Any help would be appreciated, thanks!










share|improve this question
















I am reading data from a CSV file which contains weather data for a network of buoys situated off the coast of Ireland. it is a time series dataset with hourly readings for each buoy. I want to create a 3D structure where there is a dataframe for each buoy, containing the columns of the weather conditions, indexed by the date and time.



I would like to be able to access the data via the following syntax:



df['column']['anotherColumn']


I'm aware that pandas has a deprecated Panel class, but I can't work out how to do this otherwise.



Any help would be appreciated, thanks!







python pandas






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 0:18









Xukrao

2,9754 gold badges10 silver badges34 bronze badges




2,9754 gold badges10 silver badges34 bronze badges










asked Mar 26 at 21:16









C. DunphC. Dunph

133 bronze badges




133 bronze badges










  • 2





    Use a multi level index?

    – Niels Henkens
    Mar 26 at 21:18











  • I'll look into it. I'm new to pandas so yet to work out the finer details, thanks.

    – C. Dunph
    Mar 26 at 21:20












  • 2





    Use a multi level index?

    – Niels Henkens
    Mar 26 at 21:18











  • I'll look into it. I'm new to pandas so yet to work out the finer details, thanks.

    – C. Dunph
    Mar 26 at 21:20







2




2





Use a multi level index?

– Niels Henkens
Mar 26 at 21:18





Use a multi level index?

– Niels Henkens
Mar 26 at 21:18













I'll look into it. I'm new to pandas so yet to work out the finer details, thanks.

– C. Dunph
Mar 26 at 21:20





I'll look into it. I'm new to pandas so yet to work out the finer details, thanks.

– C. Dunph
Mar 26 at 21:20












1 Answer
1






active

oldest

votes


















1














The pandas Panel was deprecated in favour of DataFrame with multi-level index. To quote from the pandas documentation:




Hierarchical / Multi-level indexing is very exciting as it opens the
door to some quite sophisticated data analysis and manipulation,
especially for working with higher dimensional data. In essence, it
enables you to store and manipulate data with an arbitrary number of
dimensions in lower dimensional data structures like Series (1d) and
DataFrame (2d).




Here's a quick example of a DataFrame with MultiIndex used to represent a three-dimensional data set:



In [1]: multi_index = pd.MultiIndex.from_arrays([
...: ['buoy1', 'buoy1', 'buoy2', 'buoy2', 'buoy3', 'buoy3', 'buoy4', 'buoy4'],
...: ['wind', 'water', 'wind', 'water', 'wind', 'water', 'wind', 'water'],
...: ])

In [2]: df = pd.DataFrame(np.random.randn(3, 8), columns=multi_index)

In [3]: df
Out[3]:
buoy1 buoy2 buoy3 buoy4
wind water wind water wind water wind water
0 1.082442 -0.148975 -0.372837 0.075599 1.681150 0.910194 0.157064 0.183764
1 -0.019759 1.782505 -1.092751 0.324313 -2.217671 0.349224 1.085250 -0.715607
2 -1.308382 -0.994506 -0.306874 0.517858 1.356037 -0.024291 0.085105 -0.073061


Subsequently you can slice down to a 2D section of your data set like so:



In [4]: df['buoy3']
Out[4]:
wind water
0 1.681150 0.910194
1 -2.217671 0.349224
2 1.356037 -0.024291


And you can slice down to a 1D section (i.e. single column) of your data set like so:



In [5]: df['buoy3']['water']
Out[5]:
0 0.910194
1 0.349224
2 -0.024291
Name: water, dtype: float64





share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366306%2fhow-to-convert-pandas-dataframe-to-3d-panel%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The pandas Panel was deprecated in favour of DataFrame with multi-level index. To quote from the pandas documentation:




    Hierarchical / Multi-level indexing is very exciting as it opens the
    door to some quite sophisticated data analysis and manipulation,
    especially for working with higher dimensional data. In essence, it
    enables you to store and manipulate data with an arbitrary number of
    dimensions in lower dimensional data structures like Series (1d) and
    DataFrame (2d).




    Here's a quick example of a DataFrame with MultiIndex used to represent a three-dimensional data set:



    In [1]: multi_index = pd.MultiIndex.from_arrays([
    ...: ['buoy1', 'buoy1', 'buoy2', 'buoy2', 'buoy3', 'buoy3', 'buoy4', 'buoy4'],
    ...: ['wind', 'water', 'wind', 'water', 'wind', 'water', 'wind', 'water'],
    ...: ])

    In [2]: df = pd.DataFrame(np.random.randn(3, 8), columns=multi_index)

    In [3]: df
    Out[3]:
    buoy1 buoy2 buoy3 buoy4
    wind water wind water wind water wind water
    0 1.082442 -0.148975 -0.372837 0.075599 1.681150 0.910194 0.157064 0.183764
    1 -0.019759 1.782505 -1.092751 0.324313 -2.217671 0.349224 1.085250 -0.715607
    2 -1.308382 -0.994506 -0.306874 0.517858 1.356037 -0.024291 0.085105 -0.073061


    Subsequently you can slice down to a 2D section of your data set like so:



    In [4]: df['buoy3']
    Out[4]:
    wind water
    0 1.681150 0.910194
    1 -2.217671 0.349224
    2 1.356037 -0.024291


    And you can slice down to a 1D section (i.e. single column) of your data set like so:



    In [5]: df['buoy3']['water']
    Out[5]:
    0 0.910194
    1 0.349224
    2 -0.024291
    Name: water, dtype: float64





    share|improve this answer































      1














      The pandas Panel was deprecated in favour of DataFrame with multi-level index. To quote from the pandas documentation:




      Hierarchical / Multi-level indexing is very exciting as it opens the
      door to some quite sophisticated data analysis and manipulation,
      especially for working with higher dimensional data. In essence, it
      enables you to store and manipulate data with an arbitrary number of
      dimensions in lower dimensional data structures like Series (1d) and
      DataFrame (2d).




      Here's a quick example of a DataFrame with MultiIndex used to represent a three-dimensional data set:



      In [1]: multi_index = pd.MultiIndex.from_arrays([
      ...: ['buoy1', 'buoy1', 'buoy2', 'buoy2', 'buoy3', 'buoy3', 'buoy4', 'buoy4'],
      ...: ['wind', 'water', 'wind', 'water', 'wind', 'water', 'wind', 'water'],
      ...: ])

      In [2]: df = pd.DataFrame(np.random.randn(3, 8), columns=multi_index)

      In [3]: df
      Out[3]:
      buoy1 buoy2 buoy3 buoy4
      wind water wind water wind water wind water
      0 1.082442 -0.148975 -0.372837 0.075599 1.681150 0.910194 0.157064 0.183764
      1 -0.019759 1.782505 -1.092751 0.324313 -2.217671 0.349224 1.085250 -0.715607
      2 -1.308382 -0.994506 -0.306874 0.517858 1.356037 -0.024291 0.085105 -0.073061


      Subsequently you can slice down to a 2D section of your data set like so:



      In [4]: df['buoy3']
      Out[4]:
      wind water
      0 1.681150 0.910194
      1 -2.217671 0.349224
      2 1.356037 -0.024291


      And you can slice down to a 1D section (i.e. single column) of your data set like so:



      In [5]: df['buoy3']['water']
      Out[5]:
      0 0.910194
      1 0.349224
      2 -0.024291
      Name: water, dtype: float64





      share|improve this answer





























        1












        1








        1







        The pandas Panel was deprecated in favour of DataFrame with multi-level index. To quote from the pandas documentation:




        Hierarchical / Multi-level indexing is very exciting as it opens the
        door to some quite sophisticated data analysis and manipulation,
        especially for working with higher dimensional data. In essence, it
        enables you to store and manipulate data with an arbitrary number of
        dimensions in lower dimensional data structures like Series (1d) and
        DataFrame (2d).




        Here's a quick example of a DataFrame with MultiIndex used to represent a three-dimensional data set:



        In [1]: multi_index = pd.MultiIndex.from_arrays([
        ...: ['buoy1', 'buoy1', 'buoy2', 'buoy2', 'buoy3', 'buoy3', 'buoy4', 'buoy4'],
        ...: ['wind', 'water', 'wind', 'water', 'wind', 'water', 'wind', 'water'],
        ...: ])

        In [2]: df = pd.DataFrame(np.random.randn(3, 8), columns=multi_index)

        In [3]: df
        Out[3]:
        buoy1 buoy2 buoy3 buoy4
        wind water wind water wind water wind water
        0 1.082442 -0.148975 -0.372837 0.075599 1.681150 0.910194 0.157064 0.183764
        1 -0.019759 1.782505 -1.092751 0.324313 -2.217671 0.349224 1.085250 -0.715607
        2 -1.308382 -0.994506 -0.306874 0.517858 1.356037 -0.024291 0.085105 -0.073061


        Subsequently you can slice down to a 2D section of your data set like so:



        In [4]: df['buoy3']
        Out[4]:
        wind water
        0 1.681150 0.910194
        1 -2.217671 0.349224
        2 1.356037 -0.024291


        And you can slice down to a 1D section (i.e. single column) of your data set like so:



        In [5]: df['buoy3']['water']
        Out[5]:
        0 0.910194
        1 0.349224
        2 -0.024291
        Name: water, dtype: float64





        share|improve this answer















        The pandas Panel was deprecated in favour of DataFrame with multi-level index. To quote from the pandas documentation:




        Hierarchical / Multi-level indexing is very exciting as it opens the
        door to some quite sophisticated data analysis and manipulation,
        especially for working with higher dimensional data. In essence, it
        enables you to store and manipulate data with an arbitrary number of
        dimensions in lower dimensional data structures like Series (1d) and
        DataFrame (2d).




        Here's a quick example of a DataFrame with MultiIndex used to represent a three-dimensional data set:



        In [1]: multi_index = pd.MultiIndex.from_arrays([
        ...: ['buoy1', 'buoy1', 'buoy2', 'buoy2', 'buoy3', 'buoy3', 'buoy4', 'buoy4'],
        ...: ['wind', 'water', 'wind', 'water', 'wind', 'water', 'wind', 'water'],
        ...: ])

        In [2]: df = pd.DataFrame(np.random.randn(3, 8), columns=multi_index)

        In [3]: df
        Out[3]:
        buoy1 buoy2 buoy3 buoy4
        wind water wind water wind water wind water
        0 1.082442 -0.148975 -0.372837 0.075599 1.681150 0.910194 0.157064 0.183764
        1 -0.019759 1.782505 -1.092751 0.324313 -2.217671 0.349224 1.085250 -0.715607
        2 -1.308382 -0.994506 -0.306874 0.517858 1.356037 -0.024291 0.085105 -0.073061


        Subsequently you can slice down to a 2D section of your data set like so:



        In [4]: df['buoy3']
        Out[4]:
        wind water
        0 1.681150 0.910194
        1 -2.217671 0.349224
        2 1.356037 -0.024291


        And you can slice down to a 1D section (i.e. single column) of your data set like so:



        In [5]: df['buoy3']['water']
        Out[5]:
        0 0.910194
        1 0.349224
        2 -0.024291
        Name: water, dtype: float64






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 27 at 0:15

























        answered Mar 27 at 0:06









        XukraoXukrao

        2,9754 gold badges10 silver badges34 bronze badges




        2,9754 gold badges10 silver badges34 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366306%2fhow-to-convert-pandas-dataframe-to-3d-panel%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현