Expected an indented block Exception












0














After running this code, i get this exception and i didn't found any place to fix it properly



import networkx as nx
from networkx.algorithms import bipartite
import numpy as np
from pandas import DataFrame, concat
import pandas as pd
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import ast
import csv
import sys

def plot_degree_dist(G):
in_degrees = G.in_degree()
in_degrees=dict(in_degrees)
in_values = sorted(set(in_degrees.values()))
in_hist = [in_degrees.values().count(x) for x in in_values]
plt.figure()
plt.grid(True)
plt.loglog(in_values, in_hist, 'ro-')
plt.plot(out_values, out_hist, 'bv-')
plt.legend(['In-degree', 'Out-degree'])
plt.xlabel('Degree')
plt.ylabel('Number of nodes')
plt.title('network of places in Cambridge')
#plt.xlim([0, 2*10**2])


I expect to receive a proper graph but all i get is this warning



  File "<ipython-input-32-f89b896484d7>", line 2
in_degrees = G.in_degree()
^
IndentationError: expected an indented block









share|improve this question







New contributor




Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0














    After running this code, i get this exception and i didn't found any place to fix it properly



    import networkx as nx
    from networkx.algorithms import bipartite
    import numpy as np
    from pandas import DataFrame, concat
    import pandas as pd
    import matplotlib.pyplot as plt
    from scipy.optimize import curve_fit
    import ast
    import csv
    import sys

    def plot_degree_dist(G):
    in_degrees = G.in_degree()
    in_degrees=dict(in_degrees)
    in_values = sorted(set(in_degrees.values()))
    in_hist = [in_degrees.values().count(x) for x in in_values]
    plt.figure()
    plt.grid(True)
    plt.loglog(in_values, in_hist, 'ro-')
    plt.plot(out_values, out_hist, 'bv-')
    plt.legend(['In-degree', 'Out-degree'])
    plt.xlabel('Degree')
    plt.ylabel('Number of nodes')
    plt.title('network of places in Cambridge')
    #plt.xlim([0, 2*10**2])


    I expect to receive a proper graph but all i get is this warning



      File "<ipython-input-32-f89b896484d7>", line 2
    in_degrees = G.in_degree()
    ^
    IndentationError: expected an indented block









    share|improve this question







    New contributor




    Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0







      After running this code, i get this exception and i didn't found any place to fix it properly



      import networkx as nx
      from networkx.algorithms import bipartite
      import numpy as np
      from pandas import DataFrame, concat
      import pandas as pd
      import matplotlib.pyplot as plt
      from scipy.optimize import curve_fit
      import ast
      import csv
      import sys

      def plot_degree_dist(G):
      in_degrees = G.in_degree()
      in_degrees=dict(in_degrees)
      in_values = sorted(set(in_degrees.values()))
      in_hist = [in_degrees.values().count(x) for x in in_values]
      plt.figure()
      plt.grid(True)
      plt.loglog(in_values, in_hist, 'ro-')
      plt.plot(out_values, out_hist, 'bv-')
      plt.legend(['In-degree', 'Out-degree'])
      plt.xlabel('Degree')
      plt.ylabel('Number of nodes')
      plt.title('network of places in Cambridge')
      #plt.xlim([0, 2*10**2])


      I expect to receive a proper graph but all i get is this warning



        File "<ipython-input-32-f89b896484d7>", line 2
      in_degrees = G.in_degree()
      ^
      IndentationError: expected an indented block









      share|improve this question







      New contributor




      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      After running this code, i get this exception and i didn't found any place to fix it properly



      import networkx as nx
      from networkx.algorithms import bipartite
      import numpy as np
      from pandas import DataFrame, concat
      import pandas as pd
      import matplotlib.pyplot as plt
      from scipy.optimize import curve_fit
      import ast
      import csv
      import sys

      def plot_degree_dist(G):
      in_degrees = G.in_degree()
      in_degrees=dict(in_degrees)
      in_values = sorted(set(in_degrees.values()))
      in_hist = [in_degrees.values().count(x) for x in in_values]
      plt.figure()
      plt.grid(True)
      plt.loglog(in_values, in_hist, 'ro-')
      plt.plot(out_values, out_hist, 'bv-')
      plt.legend(['In-degree', 'Out-degree'])
      plt.xlabel('Degree')
      plt.ylabel('Number of nodes')
      plt.title('network of places in Cambridge')
      #plt.xlim([0, 2*10**2])


      I expect to receive a proper graph but all i get is this warning



        File "<ipython-input-32-f89b896484d7>", line 2
      in_degrees = G.in_degree()
      ^
      IndentationError: expected an indented block






      csv graph jupyter-notebook pyhook






      share|improve this question







      New contributor




      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Dec 27 '18 at 18:21









      Amit Mek

      51




      51




      New contributor




      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Amit Mek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Python relies on proper indentation to identify function blocks. This code should work:



          import networkx as nx
          from networkx.algorithms import bipartite
          import numpy as np
          from pandas import DataFrame, concat
          import pandas as pd
          import matplotlib.pyplot as plt
          from scipy.optimize import curve_fit
          import ast
          import csv
          import sys

          def plot_degree_dist(G):
          in_degrees = G.in_degree()
          in_degrees=dict(in_degrees)
          in_values = sorted(set(in_degrees.values()))
          in_hist = [in_degrees.values().count(x) for x in in_values]
          plt.figure()
          plt.grid(True)
          plt.loglog(in_values, in_hist, 'ro-')
          plt.plot(out_values, out_hist, 'bv-')
          plt.legend(['In-degree', 'Out-degree'])
          plt.xlabel('Degree')
          plt.ylabel('Number of nodes')
          plt.title('network of places in Cambridge')
          #plt.xlim([0, 2*10**2])


          Basically just indent it by 2 or 4 spaces as per your style requirements.






          share|improve this answer





















          • Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
            – Amit Mek
            Dec 27 '18 at 18:34












          • Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
            – Sashi
            Dec 27 '18 at 18:35










          • Just did! :) Think you know what could be the solution of the new exception ?
            – Amit Mek
            Dec 27 '18 at 18:37










          • Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
            – Sashi
            Dec 27 '18 at 18:39










          • Yes of course, that what i will do in a minute!
            – Amit Mek
            Dec 27 '18 at 18:41











          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
          });


          }
          });






          Amit Mek is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53949250%2fexpected-an-indented-block-exception%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









          0














          Python relies on proper indentation to identify function blocks. This code should work:



          import networkx as nx
          from networkx.algorithms import bipartite
          import numpy as np
          from pandas import DataFrame, concat
          import pandas as pd
          import matplotlib.pyplot as plt
          from scipy.optimize import curve_fit
          import ast
          import csv
          import sys

          def plot_degree_dist(G):
          in_degrees = G.in_degree()
          in_degrees=dict(in_degrees)
          in_values = sorted(set(in_degrees.values()))
          in_hist = [in_degrees.values().count(x) for x in in_values]
          plt.figure()
          plt.grid(True)
          plt.loglog(in_values, in_hist, 'ro-')
          plt.plot(out_values, out_hist, 'bv-')
          plt.legend(['In-degree', 'Out-degree'])
          plt.xlabel('Degree')
          plt.ylabel('Number of nodes')
          plt.title('network of places in Cambridge')
          #plt.xlim([0, 2*10**2])


          Basically just indent it by 2 or 4 spaces as per your style requirements.






          share|improve this answer





















          • Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
            – Amit Mek
            Dec 27 '18 at 18:34












          • Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
            – Sashi
            Dec 27 '18 at 18:35










          • Just did! :) Think you know what could be the solution of the new exception ?
            – Amit Mek
            Dec 27 '18 at 18:37










          • Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
            – Sashi
            Dec 27 '18 at 18:39










          • Yes of course, that what i will do in a minute!
            – Amit Mek
            Dec 27 '18 at 18:41
















          0














          Python relies on proper indentation to identify function blocks. This code should work:



          import networkx as nx
          from networkx.algorithms import bipartite
          import numpy as np
          from pandas import DataFrame, concat
          import pandas as pd
          import matplotlib.pyplot as plt
          from scipy.optimize import curve_fit
          import ast
          import csv
          import sys

          def plot_degree_dist(G):
          in_degrees = G.in_degree()
          in_degrees=dict(in_degrees)
          in_values = sorted(set(in_degrees.values()))
          in_hist = [in_degrees.values().count(x) for x in in_values]
          plt.figure()
          plt.grid(True)
          plt.loglog(in_values, in_hist, 'ro-')
          plt.plot(out_values, out_hist, 'bv-')
          plt.legend(['In-degree', 'Out-degree'])
          plt.xlabel('Degree')
          plt.ylabel('Number of nodes')
          plt.title('network of places in Cambridge')
          #plt.xlim([0, 2*10**2])


          Basically just indent it by 2 or 4 spaces as per your style requirements.






          share|improve this answer





















          • Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
            – Amit Mek
            Dec 27 '18 at 18:34












          • Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
            – Sashi
            Dec 27 '18 at 18:35










          • Just did! :) Think you know what could be the solution of the new exception ?
            – Amit Mek
            Dec 27 '18 at 18:37










          • Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
            – Sashi
            Dec 27 '18 at 18:39










          • Yes of course, that what i will do in a minute!
            – Amit Mek
            Dec 27 '18 at 18:41














          0












          0








          0






          Python relies on proper indentation to identify function blocks. This code should work:



          import networkx as nx
          from networkx.algorithms import bipartite
          import numpy as np
          from pandas import DataFrame, concat
          import pandas as pd
          import matplotlib.pyplot as plt
          from scipy.optimize import curve_fit
          import ast
          import csv
          import sys

          def plot_degree_dist(G):
          in_degrees = G.in_degree()
          in_degrees=dict(in_degrees)
          in_values = sorted(set(in_degrees.values()))
          in_hist = [in_degrees.values().count(x) for x in in_values]
          plt.figure()
          plt.grid(True)
          plt.loglog(in_values, in_hist, 'ro-')
          plt.plot(out_values, out_hist, 'bv-')
          plt.legend(['In-degree', 'Out-degree'])
          plt.xlabel('Degree')
          plt.ylabel('Number of nodes')
          plt.title('network of places in Cambridge')
          #plt.xlim([0, 2*10**2])


          Basically just indent it by 2 or 4 spaces as per your style requirements.






          share|improve this answer












          Python relies on proper indentation to identify function blocks. This code should work:



          import networkx as nx
          from networkx.algorithms import bipartite
          import numpy as np
          from pandas import DataFrame, concat
          import pandas as pd
          import matplotlib.pyplot as plt
          from scipy.optimize import curve_fit
          import ast
          import csv
          import sys

          def plot_degree_dist(G):
          in_degrees = G.in_degree()
          in_degrees=dict(in_degrees)
          in_values = sorted(set(in_degrees.values()))
          in_hist = [in_degrees.values().count(x) for x in in_values]
          plt.figure()
          plt.grid(True)
          plt.loglog(in_values, in_hist, 'ro-')
          plt.plot(out_values, out_hist, 'bv-')
          plt.legend(['In-degree', 'Out-degree'])
          plt.xlabel('Degree')
          plt.ylabel('Number of nodes')
          plt.title('network of places in Cambridge')
          #plt.xlim([0, 2*10**2])


          Basically just indent it by 2 or 4 spaces as per your style requirements.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 27 '18 at 18:31









          Sashi

          6832617




          6832617












          • Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
            – Amit Mek
            Dec 27 '18 at 18:34












          • Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
            – Sashi
            Dec 27 '18 at 18:35










          • Just did! :) Think you know what could be the solution of the new exception ?
            – Amit Mek
            Dec 27 '18 at 18:37










          • Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
            – Sashi
            Dec 27 '18 at 18:39










          • Yes of course, that what i will do in a minute!
            – Amit Mek
            Dec 27 '18 at 18:41


















          • Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
            – Amit Mek
            Dec 27 '18 at 18:34












          • Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
            – Sashi
            Dec 27 '18 at 18:35










          • Just did! :) Think you know what could be the solution of the new exception ?
            – Amit Mek
            Dec 27 '18 at 18:37










          • Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
            – Sashi
            Dec 27 '18 at 18:39










          • Yes of course, that what i will do in a minute!
            – Amit Mek
            Dec 27 '18 at 18:41
















          Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
          – Amit Mek
          Dec 27 '18 at 18:34






          Thanks a lot, it worked! No i got another Exception .. AttributeError: 'dict_values' object has no attribute 'count'
          – Amit Mek
          Dec 27 '18 at 18:34














          Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
          – Sashi
          Dec 27 '18 at 18:35




          Great. Please feel free to mark my answer as correct so it can be useful for future users who have similar problems!
          – Sashi
          Dec 27 '18 at 18:35












          Just did! :) Think you know what could be the solution of the new exception ?
          – Amit Mek
          Dec 27 '18 at 18:37




          Just did! :) Think you know what could be the solution of the new exception ?
          – Amit Mek
          Dec 27 '18 at 18:37












          Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
          – Sashi
          Dec 27 '18 at 18:39




          Which line are you getting it on? I'm having trouble finding dict_values object. Would it be possible to create a new question for this and also share the error message? Official stackoverflow policy is that each question should only contain one problem! :)
          – Sashi
          Dec 27 '18 at 18:39












          Yes of course, that what i will do in a minute!
          – Amit Mek
          Dec 27 '18 at 18:41




          Yes of course, that what i will do in a minute!
          – Amit Mek
          Dec 27 '18 at 18:41










          Amit Mek is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Amit Mek is a new contributor. Be nice, and check out our Code of Conduct.













          Amit Mek is a new contributor. Be nice, and check out our Code of Conduct.












          Amit Mek is a new contributor. Be nice, and check out our Code of Conduct.
















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53949250%2fexpected-an-indented-block-exception%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

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas

          Can't read property showImagePicker of undefined in react native iOS